|
整合:- #include<iostream>
- using namespace std;
- int a,b,c,n;
- int main()
- {
- cout<<"======way 1======"<<endl;
- for(n=100; n<=999; n++)
- {
- a=n/100%10;
- b=n/10%10;
- c=n/1%10;
- if(a*a*a+b*b*b+c*c*c==n)
- cout<<n<<" ";
- }
- cout<<endl<<"======way 2======"<<endl;
- int abc;
- for(a=1; a<=9; a++)
- for(b=0; b<=9; b++)
- for(c=0; c<=9; c++)
- if(a*a*a+b*b*b+c*c*c==a*100+b*10+c)
- cout<<a<<b<<c<<" ";
- }
复制代码 |
|