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;

}

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