Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这也AC了?#include <stdio.h> #include <string.h> char strInput[50];//应该用5000才对吧? int main() { int res,i,a,b,c,d,x; while (1) { res = 0; scanf("%s",strInput); if (strcmp(strInput,"0")==0) return 0; x = strlen(strInput); for (i=0;i<x;i++) res +=strInput[i]-'0'; while (res>=10) { a = res/1000; b = (res-a*1000)/100; c = (res-a*1000-b*100)/10; d = res%10; res = a+b+c+d; } printf("%d\n",res); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator