标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 57905 Accepted Submission(s):
18093
24 39 0
6 3
1 #include<stdio.h> 2 #include<string.h> 3 4 int deal(int sum) 5 { 6 int total=0; 7 while(sum!=0) 8 { 9 total+=sum%10; 10 sum/=10; 11 } 12 return total; 13 } 14 15 int main() 16 { 17 char str[1002]; 18 while(gets(str)&&str[0]!=‘0‘) 19 { 20 int i,sum=0; 21 for(i=0;i<strlen(str);i++) 22 { 23 sum+=str[i]-‘0‘; 24 } 25 while(sum>9) 26 { 27 sum=deal(sum); 28 } 29 printf("%d\n",sum); 30 } 31 return 0; 32 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4600815.html