首页 > 试题广场 >

定义判断整数是否为水仙花数的函数。

[填空题]

定义判断整数是否为水仙花数的函数。利用判断水仙花数的函数,求100~1000之间所有的水仙花数。水仙花数是指一个三位数,其各位数字的立方和等于该数本身,如:153=13+53+33

【程序】

#include<stdio.h>

void main( )

{  
    int m;

    int  flower(int x)

    for(m=100;m<1000;m++)

        if ( 1 ) 【 A flower(int m)==1    B int flower(int m)==1 C flower(m)==1         D flower(x)==1

            printf(" 水仙花数 :%d\n",m);

}

2 A void  flower(int x)    B int flower(int x,int s) C int  flower(int x)     D void  flower(int x int s)

{  
    int a,b,c,s;

    a=x%10;
     3 A b=x%100%10  B b=x%10/10   C b=x/100%10  D b=x/10%10

    c=x/100;

    s=a*a*a+b*b*b+c*c*c;

    if (s==x) 
        4 ;  【 A return x;    B return 0;   C return -1;  D return 1;

    else  return 0;

}

C
C
D
D
发表于 2019-12-13 10:12:07 回复(1)