using namespace std
int main()
{
int result[5] = {0, 0, 0, 0, 0}
int num
char ch
cin >>num
for(int i = 1i <= numi++)
{
cin >>ch
if(ch != ' ' &&ch != '\n')
{
if(ch >= 'A' &&ch <= 'D')
result[ch - 'A']++
else
result[4]++
}
else
i--
}
for(int i = 0i <4i++)
{
cout <<char( 'A' + i) <<" " <<result[i] <<endl
}
cout <<"F " <<result[4] <<endl
return 0
}
main(){
int i,a=0,b=0,c=0,d=0
char a[20]
printf("")
for(i=0i<20i++)
{
scanf("%c",&a[i])
switch(a[i])
{
case 'A':a++i++break
case 'B':b++i++break
case 'C':c++i++break
case 'D':d++i++break
default:printf("选票无效!请重新输入\n")break
}
}
printf("A获得%d张选票\n",a)
printf("B获得%d张选票\n",b)
printf("C获得%d张选票\n",c)
printf("D获得%d张选票\n",d)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)