题目描述
正整数的各位数字之和被Tom称为Tom数。求输入数(<2^32)的Tom数!
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char *str;
int tom;
while(cin>>str)
{
tom=0;
int len=strlen(str);
for(int i=0;i<len;i++)
tom+=str[i]-'0';
cout<<tom<<endl;
}
return 0;
}