-->
当前位置:首页 > 题库

PROGRAMMING:Voters vote

Luz5年前 (2021-05-10)题库460
Program to count the votes of candidates. There are several candidates (n < = 10). The name of the candidate is input from the keyboard (the name of the candidate is not case sensitive, and the maximum length of the name is 9 bytes). There are several voters. The voters input the name of the candidate who wins the vote each time (the maximum length of the name is 9 bytes). If the voters input the wrong name of the candidate, it will be treated as invalid. The program automatically counts the results of each candidate's votes, and sorts them according to the order of the number of votes. Finally, the result of each voter and the information of invalid votes are output.
###Input format:
First, input the number of candidates and the names of N candidates, and then input the number of voters and the votes of M voters.
###Output format:
First, output the result of each candidate from high to low according to the vote result, and then output the information of invalid vote according to the situation of invalid vote (after line feed, output the prompt message "invalid vote:" and then output the information of invalid vote).
###Input sample 1:
```in
three
zhang
li
wang
nine
Wang
Zhang
zhuang
LI
Liao
ZHANG
WANG
Wang
wang
```
###Output sample 1:
```out
wang:4
zhang:2
li:1
invalid vote:
zhuang
Liao
```
###Input sample 2:
```in
two
liu
yang
five
Liu
liu
YANG
yang
Liu
```
###Output sample 2:
```out
liu:3
yang:2
```







answer:If there is no answer, please comment