zoukankan      html  css  js  c++  java
  • HDU 5702 Solving Order (水题,排序)

    题意:给定几种不同的颜色和它的权值,按它的权值排序。

    析:排序。

    代码如下:

    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    using namespace std ;
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f3f;
    const double eps = 1e-8;
    const int maxn = 1000 + 5;
    const int dr[] = {0, 0, -1, 1};
    const int dc[] = {-1, 1, 0, 0};
    int n, m;
    struct node{
        string s;
        int id;
        bool operator < (const node &p) const{
            return p.id < id;
        }
    };
    vector<node> v;
    
    int main(){
        int T;  cin >> T;
        while(T--){
            scanf("%d", &n);
            v.clear();
            node u;
            for(int i = 0; i < n; ++i){
                cin >> u.s >> u.id;
                v.push_back(u);
            }
            sort(v.begin(), v.end());
            for(int i = 0; i < v.size(); ++i)
                if(!i)  cout << v[i].s;
                else  cout << " " << v[i].s;
            cout << endl;
        }
        return 0;
    }
    
  • 相关阅读:
    ajax的post请求
    ajax的get请求
    浏览器缓存机制
    php和cookie
    php表单(2)
    php和表单(1)
    枚举for/in
    .Matrix-Beta冲刺的汇总博客
    .Matrix汇总博客
    小黄衫获得的感想
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5719322.html
Copyright © 2011-2022 走看看