Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大家帮我看看这个为什么错啊!!!感觉没道理 自己测试的都对啊

Posted by tianjie at 2007-06-13 20:53:37 on Problem 2181
#include <iostream.h>
void main() {
	int n,i=0,s=0,j=1,a,b=0,c;
	cin>>n;
	while(i<n){
		if(j%2) {
			cin>>a,i++;
			while(a>=b) {
				b=a;
				if(i==n) break;
				cin>>a,i++;
			} s+=b;j++;
		}
		else {
			cin>>c,i++;
			while(c<=a) {
				a=c;
				if(i==n) break;
				cin>>c,i++;
			} 
			if(i!=n) s-=a,j++;
			b=c;
		}
	}
	cout<<s<<endl;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator