|
|
back to boardwhere is my mistake #include<iostream> using namespace std; double a[100],s1,s2; int n; void read() { int i; cin>>n; for(i=0;i<n;i++) cin>>a[i]; } void z() { int i; s1=a[0]; for(i=1;i<n;i++) { if(s1<s2) s1+=a[i]; else s2+=a[i]; } if(s1<s2) cout<<s2-s1<<endl; else cout<<s1-s2<<endl; } int main () { read(); z(); return 0; } Edited by author 03.11.2009 03:34 Re: where is my mistake Posted by XMAN 10 Nov 2009 07:07 Your Solution quite wrong.Be carefully! |
|
|