int[] nums = new int[10];
int[] count = new int[4];
Console.WriteLine("请输入十个数");
for (int i = 0; i<nums.Length; i++)
{
Console.WriteLine("请输入第{0}个数字:", i + 1);
nums[i] = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < nums.Length; i++)
{
switch (nums[i])
{
case 1:
count[0] += 1;
break;
case 2:
count[1] += 1;
break;
case 3:
count[2] += 1;
break;
default:
count[3] += 1;
break;
}
}
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();
int[] nums = { 18, 25, 7, 36, 13, 2, 89, 63 }; int[] num2 = new int[nums.Length]; Array.Copy(nums, num2, nums.Length); Array.Sort(nums); int min = num2[0]; int index = Array.IndexOf(num2, min); Console.WriteLine("最小的积分是{0},下标是{1}:", min, index); Console.ReadKey();
网友评论