求C语言大神指导

我要输出100-999内的水仙花数,但是407不知道为什么总是输不出其它三个就可以好奇怪
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int action(int);
int i;
i=100;
printf("三位数水仙花数为\n");
while(i<=999)
{
action(i);
i++;
}
system("pause");
return 0;
}

int action(int n)
{
int hp,de,tu;
hp=n/100;
de=(n-100*hp)/10;
tu=n-100*hp-10*de;
if (n==pow(hp,3)+pow(de,3)+pow(tu,3))
printf("%d\n",n);
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    void action(int);
    int i;
    i=100;
    printf("三位数水仙花数为\n"); 
    while(i<=999)
    {
        action(i);
        i++;
    }
    system("pause");
    return 0;
}

void action(int n)
{
     int hp,de,tu;
     hp=n/100;
     de=(n-100*hp)/10;
     tu=n-100*hp-10*de;
     if (n==pow(hp,3)+pow(de,3)+pow(tu,3))
        printf("%d\n",n);
}

我这里是可以的

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-11-03

只加了一个return,输出没发现问题。

第2个回答  推荐于2016-01-02
改成这个
if (n==(int)(pow((float)hp,(float)3)+pow((float)de,(float)3)+pow((float)tu,(float)3)))
另外,没有retrun语句哦!
c函数库中pow似乎支持double型,C++函数库中pow支持double,float。对于int型不是警告就是报错,你的编译器应该是VC6吧?VC2005之后基本上缺省是int型报错。追问

我的是dev-c++4.9.9.1我的是win8.1装不上vc6

本回答被提问者采纳