歌手的分数
题目描述
一青年歌手参加比赛。使用C#编写-一个控制台应用,输入10位评委打分(分值只能为正整数),计算并输出歌手的平均分(去掉一一个最高分和一一个最低分)。平均分以double数据类型输出。
输入
1 2 3 4 5 6 7 8 9 10
输出
5.5
样例输入
1 2 3 4 5 6 7 8 9 10
样例输出
5.5
using System;namespace ConsoleApp4
{class Program{static void Main(string[] args){string s = Console.ReadLine();string[] str = s.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);int len = str.Length;int sum = 0, maxl = 0, minl = 0;int i = 0;int temp = Int32.Parse(str[i]);sum += temp;maxl = temp;minl = temp;for( i=1 ; i<10 ; i++ ){temp= Int32.Parse(str[i]);sum += temp;maxl = Math.Max(maxl, temp);minl = Math.Min(minl, temp);}sum = sum - (maxl + minl);double ave = (double)sum / 8.0;Console.WriteLine(ave);}}
}