Files
Story-With-Thanh/J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java
T
2022-12-15 23:51:04 +07:00

25 lines
715 B
Java

import java.util.Scanner;
import java.io.File;
import java.util.HashMap;
import java.io.FileNotFoundException;
public class Main{
public static void main(String args[]){
File x = new File("DATA.in");
try{
Scanner sc = new Scanner(x);
HashMap<Integer, Integer> a = new HashMap<Integer, Integer>();
while(sc.hasNext()){
int n = sc.nextInt();
if(a.get(n) == null) a.put(n, 1);
else a.put(n, a.get(n)+1);
}
a.forEach((key, value) ->{
System.out.printf("%d %d\n",key, value);
});
sc.close();
}catch(FileNotFoundException e){
}
}
}