标签:
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
1 #include<cstring> 2 #include<cstdio> 3 #include<iostream> 4 #include<cstdlib> 5 6 using namespace std; 7 8 int main() 9 { 10 char str[20000]; 11 while(cin>>str&&str[0]!=‘0‘) 12 { 13 int sum; 14 do{ 15 sum=0; 16 for(int i=0;i<strlen(str);i++) 17 sum+=(str[i]-‘0‘); 18 itoa(sum,str,10); //将数字转换为字符串 itoa(数字,字符串首地址,进制); 19 }while(sum>=10); 20 cout<<sum<<endl; 21 } 22 }
标签:
原文地址:http://www.cnblogs.com/wsaaaaa/p/4287459.html