题解
2025-02-22 12:16:41
发布于:广东
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int a,b[4],c;
int main(){
cin>>a;
for(int j=100;j<=a;j++){
c=j;
b[1]=c%10;
b[2]=c/10%10;
b[3]=c/100;
if(b[1]*b[1]*b[1]+b[2]*b[2]*b[2]+b[3]*b[3]*b[3]==c) cout<<c<<endl;
}
return 0;
}
不知道为什么
#include<bits/stdc++.h>
using namespace std;
int a,b[4],c;
int main(){
cin>>a;
if(a>=1000)cout<<1000<<"\n"<<1001;
for(int j=100;j<=a;j++){
c=j;
for(int i=1;i<=3;i++){
b[i]=c%10;
c/=10;
}
if(b[1]*b[1]*b[1]+b[2]*b[2]*b[2]+b[3]*b[3]*b[3]==j) cout<<j<<endl;
}
return 0;
}
会错
这里空空如也
有帮助,赞一个