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
代码:
#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;
}