Requiem


私信TA

用户名:uq_38661642959

访问量:29

签 名:

等  级
排  名 9020
经  验 1125
参赛次数 0
文章发表 2
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:拆解数字各个位上的数字,并求出立方和

注意事项:无

参考代码:

#include <stdio.h>

#include <math.h>


int main() {

    for (int i = 1; i < 1000; i++) {

        int m = i, n = i;

        int count = 0;

       

        while (m >= 1) {                       // 储存位数

            m /= 10;

            count += 1;

        }

       

        int result = 0;                          //计算各个位数上的立方和

        for (int j = 0; j < count; j++) {

            int temp_num = n % 10;

            result += pow(temp_num, 3);

            n /= 10;

        }

       

        if (i == result && i != 1) {            //判断是否相等

            printf("%d ", i);

        }

    }

   

    return 0;

}



 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区