文章
27
粉丝
86
获赞
10
访问
29.7k
C++
感觉写的好复杂啊aaa
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
vector<int> fun(int m, int n){
vector<int> res;
for(int num = m; num < n; num++){
string numS = to_string(num);
string::iterator sit;
int sum = 0;
for(sit = numS.begin(); sit != numS.end(); sit++){
sum += pow((*sit) - '0', 3);
}
if(sum == num){
res.push_back(num);
}
}
return res;
}
int main(){
int m, n;
int flag = false;
vector<int> a;
vector<int>::iterator it;
while(cin >> m >> n){
if(m == 0 && n == 0){
break;
}
a = fun(m, n);
if(a.size() == 0){
cout << "no";
}
else{
for(it = a.begin(); it != a.end(); it++){
cout << *it << " ";
}
}
cout...
登录后发布评论
暂无评论,来抢沙发