请问这个求所有水仙花数的C程序错在哪里。

来源:百度知道 编辑:UC知道 时间:2024/06/06 10:43:13
#include <stdio.h>
#include <math.h>
void fun(int n)
{
int n;
void fun(int n);
for(n=100;n<1000;n++)
if(fun(n))
printf("所有的水仙花数为:%d",n);
}

void fun(int n)
int x,y,z;
x=n%10;
y=n/10%10;
z=n/100%10;
if(pow(x,3)+pow(y,3)+pow(z,3)==n){
return 1;
else
return 0;
}
}

整个程序写的混乱,给你重新写一下
#include <stdio.h>
#include <math.h>
void main()
{

void fun();

}

void fun()
{
int x,y,z;
for(n=100;n<1000;n++)
{x=n%10;
y=n/10%10;
z=n/100%10;
if(pow(x,3)+pow(y,3)+pow(z,3)==n)
printf("水仙花:%d",n);
}

}

不懂。
怎么两个fun()?还一样的?上面的fun()里调用的是哪个fun?
最下面的花括号干嘛的?
主函数呢?