歌手的分數
題目描述
一青年歌手參加比賽。使用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);}}
}
?