The Biggest Water Proble

The Biggest Water Problem

https://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4?tpId=290&tqId=39938&sourceUrl=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Foj%3Ftab%3D%25E8%25AF%25AD%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D290

#include <stdio.h>

int main() {
    int num = 0;

    scanf("%d", &num);
    while (num >= 10) 
    {
        int sum = 0;
        while (num)
        {
            // 将num的每一位上的数字进行相加
            sum += (num % 10);
            num /= 10;
        }
        num = sum;
    }
    printf("%d", num);

    return 0;
}

全部评论

相关推荐

10-05 23:02
东北大学 Java
我说句实话啊:那时候看三个月培训班视频,随便做个项目背点八股,都能说3 40w是侮辱价
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务