201403-1 門禁系統
阿新 • • 發佈:2018-12-06
奉上java滿分程式碼
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); HashMap<Integer, Integer> hashMap = new HashMap<>(); int[] numArr = new int[n]; for(int i = 0; i < n; i++){ numArr[i] = scanner.nextInt(); hashMap.put(numArr[i], 0); } scanner.close(); for(int num : numArr){ hashMap.put(num, hashMap.get(num) + 1); System.out.print(hashMap.get(num) + " "); } } }