天天看点

每日一题:第九题

第九题:判断一个数是否为"水仙花数",所谓"水仙花数"是指一个三位数其各位数字的立方和等于该数本身。

例如:371是一个"水仙花数",371=3^3+7^3+1^3.

#include"stdio.h"

void main()

{

    int i,j,k,n;

    printf("please input the n:\n");

    scanf("%d",&n);

    printf("\n");

    i=n/100;

    j=(n-100*i)/10;

    k=n%10;

    if(i*i*i+j*j*j+k*k*k==n)

            printf("the  %d  is  Narcissistic number!\n",n);

    else 

            printf("the  %d  is  not  Narcissistic number!\n",n);

每日一题:第九题

继续阅读