-
Notifications
You must be signed in to change notification settings - Fork 1
/
DanhSachThucTap1.java
68 lines (63 loc) · 1.88 KB
/
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
61
62
63
64
65
66
67
68
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
import java.util.*;
/**
*
* @author Administrator
*/
class SinhVien implements Comparable<SinhVien>{
private int stt;
private String id;
private String ten;
private String lop;
private String mail;
private String dn;
public SinhVien(int stt, String id, String ten, String lop, String mail, String dn) {
this.stt = stt;
this.id = id;
this.ten = ten;
this.lop = lop;
this.mail = mail;
this.dn = dn;
}
public String getDn() {
return dn;
}
@Override
public int compareTo(SinhVien b){
return this.ten.compareTo(b.ten);
}
@Override
public String toString() {
return this.stt + " " + this.id + " " + this.ten + " " + this.lop + " " +
this.mail + " " + this.dn;
}
}
public class DanhSachThucTap1 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
ArrayList<SinhVien> a = new ArrayList<>();
for(int i=0; i<n; i++){
String id = sc.nextLine();
String ten = sc.nextLine();
String lop = sc.nextLine();
String mail = sc.nextLine();
String dn = sc.nextLine();
a.add(new SinhVien(i+1, id, ten, lop, mail, dn));
}
Collections.sort(a);
int t = sc.nextInt();
sc.nextLine();
while(t-- > 0){
String DN = sc.nextLine();
for(SinhVien i : a){
if(i.getDn().compareTo(DN) == 0)
System.out.println(i);
}
}
}
}