|
|
back to boardDiscussion of Problem 1068. SumI can't get Accepted and I can't my mistake ,help me please Posted by azadeh 3 Jul 2006 11:01 do you khonw why my program is wrong? #include<iostream> using namespace std; main(){ long int n; cin>>n; if(n<0){ n=-n; n=n*(n+1)/2; n=-n+1; } if(n==0) n=1; if(n>0) n=n*(n+1)/2; cout<<n; } Re: I can't get Accepted and I can't my mistake ,help me please Posted by KAV 3 Jul 2006 11:09 if(n<0) ... ELSE if( n == 0 ) ... ELSE if( n > 0 ) ... You missed "else". Without it program works wrong, of course. |
|
|