问题标题: 酷町堂:1019 3位水仙花数——help!!!

0
0
已解决
潘晨皓
潘晨皓
高级天翼
高级天翼
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;

int main(){
    for(int a=1;a<=9;++a){
        for(int b=0;b<=9;++b)
            for(int c=0;c<=9;++c)
                if(a*a*a+b*b*b+c*c*c==a*100+b*10+c){
                    cout<<setw(6)<<a+100+b*10+c;
                }
    } 
    return 0;
}

I don't know if I've left out "Narcissus is an n-digit number (n ≥ 3), and the sum of the nth powers of the numbers in each of its bits is equal to itself." this sentence???

我不清楚我是不是漏了“水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。”
这句话???

1019   3位水仙花数经验值:0

题目描述 Description

水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。
3位水仙花数则是指一个3位数,它的个位,十位和百位的数字的3次幂之和等于它本身

输入描述 Input Description

输出描述 Output Description

输出从100-999之间所有的水仙花数,并以空格分开。

样例输入 Sample Input

样例输出 Sample Output

153 3XX ... ...


0
已采纳
黄品翔
黄品翔
初级光能
初级光能

判断里面的==后面改成i;

输出要setw干什么?cout<<   的后面改成i在输出空格。

黄品翔在2020-07-05 20:18:09追加了内容

@潘晨皓

参考一下:

,循环枚举100~999每一个数

,个位、十位、百位

,满足条件时输出下面:

0
我要回答