#The Biggest Water Problem#

The Biggest Water Problem

https://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4

#include <stdio.h>
int fun(int a)
{
    int sum=0;
    while(a)
    {
        sum+=a%10;
        a/=10;
    }
    if(sum>9)
    return fun(sum);
    else
    return sum;
}
int main() {
    int a;
    scanf("%d", &a);
    printf("%d\n",fun(a));
    return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务