水仙花数
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int num, a, b, c, total; 6 scanf("%d", &num); 7 a = num / 100; 8 b = num / 10 % 10; 9 c = num % 10; 10 total = pow(a, 3) + pow(b, 3) + pow(c, 3); 11 if (total == num) 12 printf("%d=%d的次方+%d的次方+%d的次方", num, a, b, c); 13 else 14 printf("不是水仙花数"); 15 return 0; 16 }