|
|
вернуться в форумSomeone tell me why wronganswer????? I think it's very simple problem but... Here is my source! #include <stdio.h> int main(){ char ch; int sumall=0; while (!feof(stdin)) {scanf("%c",&ch); if (feof(stdin)) break;sumall+=ch-48;} //printf("s=%d",sumall); printf("%d\n",(sumall%3==0)+1); if (sumall%3) printf("%d",sumall%3); return 0; } Thanks!!! Here it is! Послано ijk 7 мар 2002 04:19 #include <stdio.h> int main(){ char ch; int sumall=0; while (!feof(stdin)) {scanf("%c",&ch); if (feof(stdin)) break; if (ch>='0' && ch<='9')sumall+=(ch-'0');}<---check at this :) sumall%=3; printf("%d",((sumall==0)+1)); if (sumall) printf("\n%d",sumall); return 0; } Thank you...I got accepted! Re: Here it is! Als0, we can use sumall+=ch instead of sumall+=(ch-'0'), because '0' == 0x30 == 3*16 :) |
|
|