ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1180. Stone Game

Show all messages Hide all messages

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 Mar 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! Vladimir Milenov Vasilev 7 Mar 2002 14:00
Re: Here it is! grandvic 22 Apr 2012 03:48
Als0, we can use sumall+=ch instead of sumall+=(ch-'0'), because '0' == 0x30 == 3*16 :)