-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.1-Zile de nastere.java
60 lines (49 loc) · 1.41 KB
/
4.1-Zile de nastere.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.*;
public class Andrei{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
String str;
ArrayList<ZiNastere> aList=new ArrayList<ZiNastere>();
for(int i=0;i<n;i++){
str=sc.next().toString().trim();
String []parts=str.split("-");
String zi=parts[0];
String luna=parts[1];
boolean t=true;
for(int z=0;z<aList.size();z++){
ZiNastere c=aList.get(z);
if(zi.equals(c.zi) && luna.equals(c.luna)){
t = false;
}
}
if(t==true){
aList.add(new ZiNastere(zi,luna));
}
}
Collections.sort(aList, Comparator.comparing(ZiNastere::getLuna).thenComparing(ZiNastere::getZi));
for(int i=0;i<aList.size();i++){
ZiNastere c=aList.get(i);
System.out.println(c.toString());
}
}
}
class ZiNastere{
String zi;
String luna;
ZiNastere(String zi,String luna){
this.zi=zi;
this.luna=luna;
}
@Override
public String toString(){
return this.zi + "-" + this.luna;
}
public String getZi(){
return this.zi;
}
public String getLuna(){
return this.luna;
}
}