/*输出m~n之间的所有水仙花数*/
#include <stdio.h> int is(int number) //调用函数
{ int a, b, c; a = number/100; b = number/10%10; c = number%10; //判断是否为水仙花数
if(number == a*a*a+b*b*b+c*c*c)
return 1; return 0; } int main () { int m, n, t, i; scanf("%d%d", &m, &n); if(m > n){ t = m; m = n; n = t; } for(i=m; i<=n; i++){ if(is(i)) printf("%d ", i); } return 0; }
//判断是否为回文数字 #include<stdio.h> int main(void) { int i,n,m; char s[10]; //输入10个字符 printf("enter 一串数字:"); i=0; while((s[i]=getchar())!=' ') i++; s[i]='