题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d ", &n);
char name[n][100];
memset(name, 0, sizeof(name));
for(int i = 0; i < n; i++){
scanf("%s ", name[i]);
}
int m;
scanf("%d ", &m);
char paper[m][100];
memset(paper, 0, sizeof(paper));
for(int i = 0; i < m; i++){
scanf("%s ", paper[i]);
}
int vote[n];
int count = 0;
memset(vote, 0, sizeof(vote));
for(int j = 0; j < n; j++){
for(int i = 0; i < m; i++){
if(strcmp(name[j], paper[i]) == 0){
vote[j]++;
count++;
}
}
printf("%s : %d\n", name[j], vote[j]);
}
printf("Invalid : %d", m - count);
return 0;
}