-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest6.cpp
More file actions
42 lines (36 loc) · 720 Bytes
/
Copy pathtest6.cpp
File metadata and controls
42 lines (36 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;
typedef struct s {
int id;
string name;
} s;
bool compare (const s &a, const s &b){
return (a.id < b.id);
}
int main()
{
ifstream fin("sort.in");
int N; fin >> N;
vector<vector<int> > B (10, vector<int> (20));
std::vector<s> A (N);
for (int i = 0; i < N; i++){
fin >> A[i].id >> A[i].name;
}
/* for (int i = 0; i < N; i++){
for (int j = i + 1; j < N; j++){
if (A[i].name < A[j].name){
myswap (A[i], A[j]);
}
}
} */
sort(A.begin(), A.end(), compare);
for (int i = 0; i < N; i++){
cout << A[i].id << " " << A[i].name << endl;
}
}