Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 79339 Accepted Submission(s): 24800
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 string str; 6 while(cin>>str&&str!="0") 7 { 8 int num=0; 9 for(int i=0;i<str.length();i++) 10 { 11 num+=str[i]-‘0‘; 12 if(num>9) 13 num=num/10+num%10; 14 } 15 cout<<num<<endl; 16 } 17 return 0; 18 }
原文:http://www.cnblogs.com/ECJTUACM-873284962/p/7214743.html