|
|
вернуться в форумI can't get Accepted and I can't my mistake ,help me please Послано azadeh 3 июл 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 Послано KAV 3 июл 2006 11:09 if(n<0) ... ELSE if( n == 0 ) ... ELSE if( n > 0 ) ... You missed "else". Without it program works wrong, of course. |
|
|