文章
2
粉丝
0
获赞
0
访问
116
#include<bits/stdc++.h>
//#include <stdio.h>
//#include <stdbool.h>
// 判断一个数是否为水仙花数
bool isNarcissistic(int num) {
int hundreds = num / 100;
int tens = (num / 10) % 10;
int ones = num % 10;
return num == hundreds * hundreds * hundreds + tens * tens * tens + ones * ones * ones;
}
int main() {
int m, n;
while (scanf("%d%d", &m, &n) && (m != 0 || n != 0)) {
bool found = false;
printf(""); // 输出一个空行,用于分隔不同的测试实例输出(根据题目要求,可能不需要,但这里为了清晰加上)
for (int i = m; i <= n; i++) {
if (isNarcissistic(i)) {
if (found) {
printf(" "); // 在多个水仙花数之间添加一个空格
 ...
登录后发布评论
暂无评论,来抢沙发