题目地址:点击打开链接
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
char m[1000],len,ans;
while(scanf("%s",m)!=EOF)
{
len=strlen(m);
if(m[0]=='0')break;
ans=m[0]-'0';
for(int i=1;i<len;i++)
{
int a,b,tmp;
tmp=m[i]-'0'+ans;
if(tmp>=10)
{
a=tmp/10;b=tmp%10;
ans=a+b;
}
else
ans=tmp;
}
printf("%d\n",ans);
}
return 0;
}