题解 | #The Biggest Water Problem#
The Biggest Water Problem
http://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4
开始写的时候一直没想明白调用,后面用了一个nn来记录每一次函数调用后的值用来判断
#include<stdio.h>
int chuli(int n){
int sum=0;
while(n!=0){
sum+=n%10;
n=n/10;
}
return sum;
}
int main(){
int n,nn;
scanf("%d",&n);
nn=chuli(n);
while(nn>=10){
nn=chuli(nn);//不断赋值不断调用
}
printf("%d",nn);
}