我想问一下大家,我这个“最高分者”跟“高于平均分的人”都不对,我找不到原因,有人帮我看一下吗?谢谢你们
static void Main(string[] args) { string[] name = new string[2]; int[] score = new int[2]; for (int i=0;i<name.Length;i++) { Console.WriteLine("输入第" + (i + 1) + "位的姓名:"); name[i] = Console.ReadLine(); Console.WriteLine("输入第" + (i + 1) + "位的分数:"); score[i] = int.Parse(Console.ReadLine()); } int sum=0,avg; for (int i=0;i<score.Length;i++) { sum += score[i]; } avg = sum / score.Length; Console.WriteLine("总分数:{0}平均分:{1}",sum,avg); int max=0; string topone=null; for (int j=1;j<score.Length;j++) { if (score[j] > max) max = score[j]; topone = name[j]; } Console.WriteLine("最高分是{0}", max); Console.WriteLine("最高分者是{0}",topone); int avgp=score[0]; string avgpp =name[0]; for (int k=1;k<score.Length;k++) { if (score[k] > avg) avgp = score[k]; avgpp = name[k]; } Console.WriteLine("高于平均分的人有{0}",avgpp); Console.ReadLine(); } }}