| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大家帮我看看这个为什么错啊!!!感觉没道理 自己测试的都对啊#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator