-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDanh_sach_thi_lap_trinh.cpp
75 lines (71 loc) · 1.38 KB
/
Danh_sach_thi_lap_trinh.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <bits/stdc++.h>
using namespace std;
class Team{
public:
string ma,ten,truong;
static int cnt;
public:
void nhap(){
cnt++;
string s=to_string(cnt);
ma="Team"+string(2-s.size(),'0')+s;
cin>>ten;
getline(cin,truong);
}
void in(){
cout<<" "<<ten<<" "<<truong<<endl;
}
};
int Team::cnt=0;
class ThiSinh: public Team{
private:
string mathisinh,tensv,mateam;
string school, tenteam;
static int dem;
public:
void nhap(){
dem++;
string s=to_string(dem);
mathisinh="C"+string(3-s.size(),'0')+s;
cin.ignore();
getline(cin,tensv);
cin>>mateam;
}
void in(){
cout<<mathisinh<<" "<<tensv<<" ";
Team::in();
}
friend bool operator < (ThiSinh a,ThiSinh b){
return a.tensv<b.tensv;
}
friend void process(Team [],int,ThiSinh [],int);
};
void process(Team ds[], int n, ThiSinh p[], int m){
for(int i = 0; i < m; i ++){
for(int j = 0; j < n; j ++){
if(p[i].mateam == ds[j].ma)
p[i].school = ds[j].truong;
p[i].tenteam = ds[j].ten;
}
}
sort(p, p + m);
}
int ThiSinh::dem=0;
int main(){
int n, m;
cin >> n >> m;
cin.ignore();
Team t[100];
ThiSinh ts[1000];
for (int i = 0; i < n; i++) {
t[i].nhap();
}
for (int i = 0; i < m; i++) {
ts[i].nhap();
}
process(t, n, ts, m);
for (int i = 0; i < m; i++) {
ts[i].in();
}
return 0;
}