文章

5

粉丝

0

获赞

3

访问

149

头像
数字排序 题解:
P1966 华东师范大学2023年机试
发布于2026年1月7日 14:32
阅读数 36

#include <bits/stdc++.h>
using namespace std;

// 定义普通比较函数
bool compare(const string& a, const string& b) {
    return stod(a) < stod(b);
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(auto &i : s)
        cin >> i;
    
   
    sort(s.begin(), s.end(), compare);
    
    for (auto &num : s) {
        cout << num << endl;
    }
    return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发