黑猫警长在犯罪现场发现了一些血迹,现已经委托检验机构确定了血型,需要统计各种血型的样本数目。
输入:血型序列(A/B/O/C,C代表AB型血,输入以X结束)
输出:各种血型的数量
输入样例:ABCAOCOAOOBX
输出样例:A:3 B:2 O:4 AB:2
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int a=0, b=0, ab=0, o=0;
char blood;
while((blood=getchar())!='X')
{
switch (blood)
{
case 'A' :
a++;
break;
case 'B' :
b++;
break;
case 'C' :
ab++;
break;
case 'O' :
o++;
break;
}
}
cout<<"A:"<<a<<" ";
cout<<"B:"<<b<<" ";
cout<<"O:"<<o<<" ";
cout<<"AB:"<<ab<<endl;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int a=0, b=0, ab=0, o=0;
char blood;
while((blood=getchar())!='X')
{
switch (blood)
{
case 'A' :
a++;
break;
case 'B' :
b++;
break;
case 'C' :
ab++;
break;
case 'O' :
o++;
break;
}
}
cout<<"A:"<<a<<" ";
cout<<"B:"<<b<<" ";
cout<<"O:"<<o<<" ";
cout<<"AB:"<<ab<<endl;
return 0;
}