|
|
back to boardWhere is my mistake? WHERE IS MY MISTAKE??? #include <iostream> #include <cmath> using namespace std; int main () { int a[100000],n,i,s1=0,s2=0,min; cin>>n; for (i=1;i<=n;i++) cin>>a[i]; for (i=1;i<=n;i++) { if (s1>s2) s2+=a[i]; else if (s1==s2) s1+=a[i]; else s1+=a[i]; } min=abs (s1-s2); cout<<min<<endl; return 0; } Re: Where is my mistake? Posted by OpenGL 20 Mar 2009 14:08 Try this test 5 10 10 8 4 8 Right answer is 0 Edited by author 20.03.2009 14:09 Re: Where is my mistake? My answer is 4.Why is 0? Re: Where is my mistake? Posted by OpenGL 23 Mar 2009 17:54 10+10=8+4+8=20 Re: Where is my mistake? Thanks!!! Re: Where is my mistake? Posted by aleko 13 May 2009 15:13 my answer is 4 too Re: Where is my mistake? Hey do you know test #5 |
|
|