题解 | #The Biggest Water Problem#
The Biggest Water Problem
http://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4
#include <stdio.h>
int fun(long long int n){
long long int m,sum=0,i;
m=n;
while(m!=0){
sum+=m%10;
m/=10;
}
i=sum;
if(i<10) return i;
else return fun(i);
}
int main(){
long long int n;
scanf("%lld",&n);
printf("%d",fun(n));
}
int fun(long long int n){
long long int m,sum=0,i;
m=n;
while(m!=0){
sum+=m%10;
m/=10;
}
i=sum;
if(i<10) return i;
else return fun(i);
}
int main(){
long long int n;
scanf("%lld",&n);
printf("%d",fun(n));
}