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;
}