package snippet;
import java.util.*;
public class Snippet {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n1 = sc.nextInt();
String[] name = new String[n1];
for(int i=0;i<n1;i++){
name[i] = sc.next();
}
int n2 = sc.nextInt();
String[] votes = new String[n2];
for(int j=0;j<n2;j++){
votes[j] = sc.next();
}
sc.close();
int[] c = new int[n1];
int invalid=0;
for(int k=0;k<votes.length;k++){
for(int l=0;l<name.length;l++){
if(votes[k].equals(name[l])){
c[l]++;
break;
}
if(l==name.length-1){
invalid++;
}
}
}
for(int m=0;m<n1;m++){
System.out.println(name[m]+" : "+c[m]);//注意冒号两边要有空格
}
System.out.print("Invalid : "+invalid);
}
}
网友评论