歡迎指正!
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? ?static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int sum = 0,avg;
? ? ? ? ? ? string[] name = new string[] { "景珍", "林慧祥", "成蓉", "紅南昌", "龍玉民", "單江開", "田武山", "王三明" };
? ? ? ? ? ? int[] score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum += score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg = sum / score.Length;
? ? ? ? ? ? Console.Write("平均分是{0}, 高于平均分的有:", avg);
? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (avg<score[i])
? ? ? ? ? ? ? ? {??
? ? ? ? ? ? ? ? ? ? Console.Write(name[i]+" ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2020-12-26
Console.WriteLine();是多余的,把第一個(gè)Console.Write()換成Console.WriteLine()就行了