#include <stdio.h>
int main(void)
{int x;int count[10];int i;for(i=0;i<10;i++){//初始化数组 count[i]=0;}scanf("%d",&x);while(x!=-1){if( x>=0 && x<=9){count[x]++;//数组参与运算 }scanf("%d",&x);}for(i=0;i<10;i++){printf("%d:%d\n",i, count[i]);}return 0;
}
运行结果: