题目来源:码蹄集
https://matiji.net/exam/brushquestion/234/778/B3FCFEC101BD05189BB74D522E019504
参考代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define N 1000
#define ll long long
int n;
int main(){
cin >> n;
while (n / 10 >= 1){
int n1= n;
n = 0;
while (n1){
n += n1 % 10;
n1 = n1 / 10;
}
}
cout.width(3);
cout << n ;
return 0;
}