C语言玫瑰花数,27写一个函数判断某一个四位数是不是玫瑰花数 用C语言写

1,27写一个函数判断某一个四位数是不是玫瑰花数 用C语言写#include<stdio.h>#include<math.h>void main(){ scanf("请输入任意一个千位数:%d",n); int total=0; int chushu=10000; int x=n; while(chushu!=1) { x=n%chushu; total+=pow(x/(chushu/10),4); chushu /= 10; } string result = total==n?"yes":"no"; printf(result);}
2,如果一个四位数等于它的各数位上的数字的四次方和则称玫瑰花数C语言程序代码如下:#include <stdio.h>#include <math.h> int main(void)if (sum == i)}printf("\n");system("pause");return (0); }www.gm199.com 传奇开服一条龙问你下提问者否知道答案,或者根本就没有这种等式 , 如果没有的话,我想就是数学家来了也会被你难倒a(1000a-a*3)+b(100B-b*3)+c(10c-c*3)+d(1-d*3)=01000a+100b+10c+d=a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d 不会写四次方2002a+b+c+d+1000a+100b+10c+d=20061001a+101b+11c+2d=2006a=2,b=0,c=0,d=2for($i=0;$i<=10000;$i++)$rr=$i;$e1=(int)mb_substr($rr,0,1,"UTF-8");$e2=(int)mb_substr($rr,1,1,"UTF-8");$e3=(int)mb_substr($rr,2,1,"UTF-8");$e4=(int)mb_substr($rr,3,1,"UTF-8");$rt1=$e1*$e1*$e1*$e1;$rt2=$e2*$e2*$e2*$e2;$rt3=$e3*$e3*$e3*$e3;$rt4=$e4*$e4*$e4*$e4;$rt11=$rt1+$rt2+$rt3+$rt4;if($i==$rt11)print_r($rt11);echo"</br>";}}exit;结果:163482089474-----这是程序员的程序,和你要的程序有差别【C语言玫瑰花数,27写一个函数判断某一个四位数是不是玫瑰花数 用C语言写】

    推荐阅读