|
|
вернуться в форумWhere is my mistake?Tell me please.C++. WA# 9 #include"iostream.h" double S,n,i; int main() { cin>>n; if(n==0) S=1; if(n>0) for(i=1;i<=n;i++) S=S+i; if(n<0) for(i=1;i>=n;i--) S=S+i; cout<<S<<endl; return 0; } Re: Where is my mistake?Tell me please.C++. WA# 9 Mihran you must set value of S equal to zero,before "for(...) S=S+i;".Good luck! Edited by author 07.05.2009 17:39 Re: Where is my mistake?Tell me please.C++. WA# 9 why the compiler does not accept the job site? that do not correctly? #include <iostream> #include <math.h> using namespace std; int main() { int N; int H=0; int S=0; int i; cin>>N; if(((N<10000)&&(N>1))||((N>-10000)&&(N<-1))) { H=abs(N); for( i=2;i<=H;i++) S=S+i; if(N<0) cout<<endl<<S*(-1); else cout<<endl<<S;} else cout<<"error"; return 0; } Re: Where is my mistake?Tell me please.C++. WA# 9 Послано psheno 3 апр 2011 22:37 n=0 |
|
|