机智的末位无空格

来源:互联网 发布:阿里云客服工作台 编辑:程序博客网 时间:2024/05/01 00:12
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int f(int x)
 {int y=1;
 for(int i=1;i<=3;i++)
  y=y*x;
 return y;}
int main()
{
int a,b,c,d;
while(cin>>a>>b){
c=0;
d=0;
 for(int i=a;i<=b;i++)
 {if(f(i%10)+f(i/10%10)+f(i/100%10)==i){
if(d) {cout<<" ";}   //机智的末尾无空格
d=1;    cout<<i;c++;}
     
  }
if(c<1) cout<<"no";
 cout<<endl;}
 return 0;
}
0 0
原创粉丝点击