栩修染


私信TA

用户名:soungkayou

访问量:999

签 名:

I like it when you smile. But I love it when I'm the reason.

等  级
排  名 10129
经  验 1054
参赛次数 1
文章发表 5
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:

提取百位数:a/100(例如:371/100=3)

提取十位数:(a/10)%10(例如:371/10=37    37%10=7)                

提取个位数:a%10(例如:371%10=1)


参考代码:

#include<stdio.h>

#include<math.h>

int fun(int a){ //判断是否为水仙花数

    return a==(pow((a/100),3)+pow(((a/10)%10),3)+pow((a%10),3));

}

int main()

{

    int a;

    scanf("%d", &a);

    printf("%d",fun(a));

    return 0;

}


 

0.0分

1 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区