#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入10个数字:");
int[] nums = new int[10];
for(int i=0;i<10;i++)
{
Console.Write("你输入的第{0}个数字",i+1);
nums[i] = Convert.ToInt32(Console.ReadLine());
}
int x=0;
int[] count = { 0, 0, 0, 0 };
do
{
switch (nums[x])
{
case 1:
count[0]++;
x++;
break;
case 2:
count[1]++;
x++;
break;
case 3:
count[2]++;
x++;
break;
default:
count[3]++;
x++;
break;
}
} while (x < 10);
Console.WriteLine("输入的1个数为{0}", count[0]);
Console.WriteLine("输入的2个数为{0}", count[1]);
Console.WriteLine("输入的3个数为{0}", count[2]);
Console.WriteLine("输入的非法数字个数为{0}", count[3]);
Console.ReadKey();
}
}
}
#效果
网友评论