2876: 吃货排排坐

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 73  Solved: 52
[Submit][Status][Web Board]

Description

输入多名同学喜欢吃的零食,0是饼干,1是虾条,2是QQ糖。统计出喜欢吃这3种零食的同学人数

Input

数字表示的多名同学喜欢吃的零食,以-1结束

Output

喜欢吃这3种零食的同学人数,各占一行

Sample Input

0 1 2 2 1 0 0 2 1 1 2 0 0 1 -1

Sample Output

5
5
4

HINT

Source

hlj


代码:

#include<stdio.h>
int main()
{
int i,t;
int a;
int b=0,x=0,q=0;
while(scanf("%d",&a))
{
if(a==-1)break;
if(a==0)b++;
else if(a==1)x++;
else q++;
}
printf("%d\n%d\n%d",b,x,q);
return 0;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章