|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有没有大神会做这个题目,紧急
键盘输入n个人的选票数据,每个选票上有五个候选人,其数据记录的格式使用一个五位的二进制数来表示,第一位表示第一位候选人选中的情况,第二位表示第二位候选人选中的情况,以此类推,其内容均为字符0或1,1表示被选中,0表示未被选中。例如11010,此选票表示第1、2和4个候选人被选中,而第3和5个候选人未被选中。试编写函数counts来统计并输出各候选人的所得票数。
(1)函数格式如下:void counts(int n,char (*p)[6]){}
(2)输入输出格式如下:
例如:输入为:
10011
01101
10011
11011
00010
输出为:
the candidate 1 wins 3 votes!
the candidate 2 wins 2 votes!
the candidate 3 wins 1 votes!
the candidate 4 wins 4 votes!
the candidate 5 wins 4 votes! |
|