比赛评分
在一项比赛评分中,有10个评委为参与的选手打分,分数为1到100分,选手最后得分为:去掉一个最高分和一个最低分其余8个数的平均值。
程序实现如下:
程序实现如下:
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Test
6 {
7 class Program
8 {
9 static void Main(string[] args)
10 {
11 int number,i, max, min, sum;
12 max = -32768;
13 min = 32767;
14 sum = 0;
15 for (i = 1; i <= 10; i++)
16 {
17 Console.WriteLine("Input No {0}:", i);
18 number = Convert.ToInt32(Console.ReadLine());
19 sum += number;
20 if (number > max)
21 max = number;
22 if (number < min)
23 min = number;
24 }
25 Console.WriteLine("Canceled Max score:{0},Canceled Min score:{1}", max, min);
26 Console.WriteLine("Average score:{0}", (sum - max - min) / 8);
27
28 }
29 }
30 }
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Test
6 {
7 class Program
8 {
9 static void Main(string[] args)
10 {
11 int number,i, max, min, sum;
12 max = -32768;
13 min = 32767;
14 sum = 0;
15 for (i = 1; i <= 10; i++)
16 {
17 Console.WriteLine("Input No {0}:", i);
18 number = Convert.ToInt32(Console.ReadLine());
19 sum += number;
20 if (number > max)
21 max = number;
22 if (number < min)
23 min = number;
24 }
25 Console.WriteLine("Canceled Max score:{0},Canceled Min score:{1}", max, min);
26 Console.WriteLine("Average score:{0}", (sum - max - min) / 8);
27
28 }
29 }
30 }