c语言中什么是玫瑰花数

要有代码就好了,要能运行的啊

# include <iostream.h>
# include <math.h>
# define SIZE 10
int main()
{
long i,j;
long a[SIZE];
long temp;
long count=0;
long sum=0;
cout<<"玫瑰花数:"<<endl;
for(i=(long)(pow(10,4-1));i<(long)pow(10,4);i++)
{
temp=i;
while(temp!=0)
{
a[count++]=temp%10;
temp/=10;
}
for(j=0;j<count;j++)
{
sum+=(long)(pow(a[j],4));
}
if(sum==i)
{
while(count>1)
{
cout<<a[--count]<<"^"<<4<<"+";
}
cout<<a[--count]<<"^"<<4<<"="<<sum<<endl;
}
sum=0;
count=0;
}
return 0;
}
可以了哈,试试嘛追问

哥哥,你这好深奥啊,我的大一才学的,您看看,简单点

追答

# include
void main()
{
int i,j;
int a[10];
int temp;
int count=0;
int sum=0;
for(i=1000;i<10000;i++)
{
temp=i;
while(temp!=0)
{
a[count++]=temp%10; //把一个数的每一位取出来放进数组a中
temp=temp/10;
}
for(j=0;j<count;j++)
{
sum+=(a[j]*a[j]*a[j]*a[j]);//求每一位数的四次方
}
if(sum==i)
{
printf("%d is a rose number that is you wanted...\n",sum);
}
sum=0;
count=0;
}
}
这样总行了吧

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-26
# include <stdio.h>
# include <math.h>
int main(void)

{
int i;
int s;
int a,b,c,d;
for(i=1000;i<10000;++i)

{
a = i/1000;
b = (i/100)%10;
c = (i/10)%10;
d = i%10;
s = pow(a,4) + pow(b,4) + pow(c,4) + pow(d,4);

if (s == i)

printf("这个数为玫瑰花数:%d\n", i);
}
return 0;
}本回答被网友采纳
第2个回答  2020-02-27
c语言中的玫瑰花数是指一个四位数等于它的各数位上的数字的四次方和。

c语言介绍;C语言是一门通用计算机编程语言,应用广泛,C语言的设计目标是提供一种能以简易的方式编译,产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网