level 10
do-while缩小的是number变量,所以while()里面对number做限制, 不能n。
2022年11月16日 15点11分
3
level 10
#include <stdio.h>
#include <math.h>
int main() {
int n, j, number;
double product; // 乘积
printf("水仙花数: \n");
for (n = 100; n < 1000; n++) {
product = 0;
number = n;
do {
j = number % 10; // 个位上的数 j
product = product + pow(j, 3);
number = number / 10; // 利用除号取整缩小10倍
} while (number != 0);// 【这里改下】
if (n == product)
printf("%d\n", n);
}
return 0;
}
2022年11月16日 15点11分
4
嗯嗯,才发现的问题
2022年11月16日 15点11分