分析
c++
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string str;
int toSum(string s){
int n=s.size();
int sum=0;
for(int i=0;i<n;i++){
sum+=s[i]-'0';
}
return sum;
}
int main(){
cin>>str;
int s=toSum(str);
while(s>9){
s=toSum(to_string(s));
}
cout<<s<<endl;
return 0;
}