文章
68
粉丝
691
获赞
26
访问
577.9k
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define ll int
#define MAX 1005
#define inf 0x3fffff
#define vec vector<ll>
int main() {
string s;
while (cin >> s && s != "0") {
ll res = 0;
for (int i = 0; i < s.size(); i++)
res += s[i] - '0';
while (res >= 10) {
s = to_string(res);
res = 0;
for (int i = 0; i < s.size(); i++)
res += s[i] - '0';
}
cout << res << endl;
}
}
登录后发布评论
暂无评论,来抢沙发