参考代码:
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); int num[]=new int [8]; HashMap<Integer, Integer> mmMap=new HashMap<Integer, Integer>(); for (int i = 0; i < 7; i++) { int h=scanner.nextInt(); mmMap.put(h, h); } for (int i = 0; i < n; i++) { int count=0; for (int j = 0; j < 7; j++) { int h1=scanner.nextInt(); if (mmMap.containsKey(h1)) { count++; } } num[count]++; } for (int i = num.length-1; i >=1 ; i--) { System.out.print(num[i]+" "); } } }
0.0分
1 人评分
A+B for Input-Output Practice (VI) (C语言代码)浏览:564 |
矩阵的对角线之和 (C语言代码)浏览:1363 |
1052题解(链表操作)浏览:708 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:461 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:777 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:663 |
多组数据新方法浏览:356 |
三角形 (C语言代码)浏览:675 |
C二级辅导-求偶数和 (C语言指针动态内存法)浏览:652 |
A+B for Input-Output Practice (III) (C++代码)浏览:566 |