定义判断整数是否为水仙花数的函数。利用判断水仙花数的函数,求100~1000之间所有的水仙花数。水仙花数是指一个三位数,其各位数字的立方和等于该数本身,如:153=13+53+33
【程序】
#include<stdio.h>
void main( )
int flower(int x) ;
for(m=100;m<1000;m++)
if ( 1 )
printf(" 水仙花数 :%d\n",m);
}
2
a=x%10;
3
c=x/100;
s=a*a*a+b*b*b+c*c*c;
if (s==x) 4 ;
else return 0;
(1) A 、 flower(int m)==1 B 、 int flower(int m)==1 C 、 flower(m)==1 D 、 flower(x)==1
(3) A 、 b=x%100%10 B 、 b=x%10/10 C 、 b=x/100%10 D 、 b=x/10%10
(4) A 、 return x; B 、 return 0; C 、 return -1; D 、 return 1;