作者在 2010-05-13 09:22:56 发布以下内容
#include<stdio.h>
void main()
{
int i=0,n[10]={0};
do {
printf("Please enter a number:\n");
scanf("%d",&i);
if(i>=0&&i<=9)
{
if (i!=-1){
printf("You just enter the number is:%d\n",i);
switch(i)
{
case 0:n[0]++;break;
case 1:n[1]++;break;
case 2:n[2]++;break;
case 3:n[3]++;break;
case 4:n[4]++;break;
case 5:n[5]++;break;
case 6:n[6]++;break;
case 7:n[7]++;break;
case 8:n[8]++;break;
case 9:n[9]++;break;
}
}
}
else
{
printf("input error!\n");
}
}while(i!=-1);
for(i=0;i<10;i++)
printf("有%d个%d;\n",n[i],i);
}
{
int i=0,n[10]={0};
do {
printf("Please enter a number:\n");
scanf("%d",&i);
if(i>=0&&i<=9)
{
if (i!=-1){
printf("You just enter the number is:%d\n",i);
switch(i)
{
case 0:n[0]++;break;
case 1:n[1]++;break;
case 2:n[2]++;break;
case 3:n[3]++;break;
case 4:n[4]++;break;
case 5:n[5]++;break;
case 6:n[6]++;break;
case 7:n[7]++;break;
case 8:n[8]++;break;
case 9:n[9]++;break;
}
}
}
else
{
printf("input error!\n");
}
}while(i!=-1);
for(i=0;i<10;i++)
printf("有%d个%d;\n",n[i],i);
}