题解

The Biggest Water Problem

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

#include <stdio.h>
int test(int c)
{
    int b=0;
    while (c != 0)
    {
        b += c % 10;
        c = c / 10;
    }
    return (b);
}
int main() {
    int a;
    scanf("%d",&a);
    int sum=0;
    sum=test(a);
    while(sum/10!=0)
    {
        sum=test(sum);
    }
    printf("%d",sum);
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务