血型统计

来源:互联网 发布:linux 多tomcat配置 编辑:程序博客网 时间:2024/04/27 22:47
#include <iostream>#include <iomanip>using namespace std;int main(){  int a=0, b=0, ab=0, o=0;  char blood;  cin>>blood;  while(blood!='X')  {    switch (blood)    {    case 'A' :      a++;      break;    case 'B' :      b++;      break;    case 'C' :      ab++;      break;    case 'O' :      o++;      break;    }  cin>>blood;  }  cout<<"A:"<<a<<endl;  cout<<"B:"<<b<<endl;  cout<<"O:"<<o<<endl;  cout<<"AB:"<<ab<<endl;  return 0;}

输出结果:

学习总结:开始不懂,后来发现,怎么这么简单,忘输break;了

0 0
原创粉丝点击