文章
8
粉丝
27
获赞
24
访问
699
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
getline(cin, s);
istringstream iss(s);
vector<long long> v;
long long x;
while (iss >> x) {
v.push_back(x);
}//这么长都是为了把数字读入v这个数组。。。隔壁python读入只要一行就能存进列表
sort(v.begin(), v.end(), [](long long a, long long b) {
int la = to_string(abs(a)).size();
int lb = to_string(abs(b)).size();
return (la != lb) ? (la > lb) : (a < b); // 双条件排序
});
for (auto& num : v) {
cout << num << ' ';
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发