-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiaChiEmail.java
57 lines (54 loc) · 1.6 KB
/
DiaChiEmail.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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package codeptit;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeSet;
/**
*
* @author Administrator
*/
public class DiaChiEmail {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
List<String> l = new ArrayList<>();
while(t-- > 0) {
String s = sc.nextLine();
s = s.toLowerCase();
StringTokenizer st = new StringTokenizer(s);
String res = "";
List<String> tmp = new ArrayList<>();
while(st.hasMoreTokens()){
tmp.add(st.nextToken());
}
res += tmp.get(tmp.size()-1);
for(int i=0; i<tmp.size()-1; i++){
res += tmp.get(i).charAt(0);
}
l.add(res);
}
for(int i=0; i<l.size(); i++){
int cnt = 1;
for(int j=i-1; j>=0; j--){
if(l.get(i).compareTo(l.get(j)) == 0){
cnt++;
}
}
String x = "";
if(cnt > 1){
x = l.get(i).concat(String.valueOf(cnt));
}
else{
x = l.get(i);
}
System.out.printf("%[email protected]", x);
System.out.println();
}
}
}