-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05034_DanhSachThucTap1.java
60 lines (52 loc) · 1.62 KB
/
J05034_DanhSachThucTap1.java
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
import java.util.*;
import java.lang.*;
import java.math.*;
class SinhVien {
private int stt;
private String id, name, lop, mail, dn;
public SinhVien(int i, String msv, String ht, String l, String email, String dn) {
this.stt = i;
this.id = msv;
this.name = ht;
this.mail = email;
this.lop = l;
this.dn = dn;
}
public String getDn() {
return this.dn;
}
public String getName() {
return this.name;
}
@Override
public String toString() {
return String.valueOf(stt) + " " + this.id + " " + this.name + " " + this.lop + " " + this.mail + " " + this.dn;
}
}
public class J05034_DanhSachThucTap1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
ArrayList<SinhVien> sv = new ArrayList<>();
for (int i = 1; i <= n; i++) {
sv.add(new SinhVien(i, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine()));
}
Collections.sort(sv, new Comparator<SinhVien>() {
@Override
public int compare(SinhVien t, SinhVien t1) {
return t.getName().compareTo(t1.getName());
}
});
int t = sc.nextInt();
sc.nextLine();
while (t-- > 0) {
String search = sc.nextLine();
for (SinhVien p : sv) {
if (p.getDn().equals(search)) {
System.out.println(p);
}
}
}
}
}