메뉴 닫기

C++ Pair Vector의 정렬

#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<pair<int, string>> p;
    int n, no;
    string name;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> no >> name;
        p.push_back(make_pair(no, name));
    }

    for(int i=0; i<p.size(); i++)
        cout << p[i].first << " " <<p[i].second << endl;

    sort(p.begin(), p.end());

    for(int i=0; i<p.size(); i++)
        cout << p[i].first << " " <<p[i].second << endl;

    return 0;
}

2 Comments

  1. karışık porno

    Amy, I just baked these and they are very good. Mildly sweet flavor with wonderful texture. Loved the convenience of the one bowl preparation, and the fact that I keep most of the suggested ingredients on hand will make these a handy go to. I am not a baker, and your tips and recommendations are much appreciated. Lacy Esshaki

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다