题解 | 大水题
大水题
https://www.nowcoder.com/practice/6b9770de551c426287252421742f6ebf
#include <stdio.h>
int he(int n){
int sum=0;
while(n>0){
sum+=n%10;
n/=10;
}
return sum;
}
int hanshu(int n){
int m=he(n);;
if(m<10){
return m;
}else{
return hanshu(m);
}
}
int main() {
int n;
int result;
scanf("%d",&n);
result=hanshu(n);
printf("%d",result);
return 0;
}