|
|
back to boardDiscussion of Problem 1068. Sumwho can help me ? my cpp file #include <stdio.h> int main(){ int num; int answer; scanf("%d",&num); if(num>=0){ for(;num>=1;num--) answer += num; } else{ for(;num<=-2;num++) answer += num; } printf("%d\n",answer); return 0; } where is the wrong ? Re: who can help me ? 1) int answer; // wrong int answer = 0; // right 2) for 0 answer is 1, not 0 Re: who can help me ? thank you ! I have known where is wrong .thank you all the same! |
|
|