文章
6
粉丝
73
获赞
0
访问
3.3k
#include <stdio.h>
#include <math.h>
// 检查是否为水仙花数
int isShuixianhua(int num) {
int sum = 0;
int originalNum = num;
while (num > 0) {
int digit = num % 10;
sum += pow(digit, 3);
num /= 10;
}
return (sum == originalNum);
}
// 输出范围内的水仙花数
void printShuixianhuaIn(int start, int end) {
int found = 0;
for (int i = start; i <= end; i++) {
if (isShuixianhua(i)) {
printf("%d ", i);
found = 1;
}
}
if (found==0) {
printf("no");
}
printf("\n");
}
int main() {
int a, b;
while (...
登录后发布评论
暂无评论,来抢沙发