大佬们,帮忙再优化下代码,谢谢
static void Main(string[] args)
{
string []name = new string[]{"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};
double []score =new double[]{90,65,88,70,46,81,100,68};
double avg =0;
double sum = 0; // 声明变量;
for (int i =0;i<score.Length;i++)
{
sum+=score[i];
} // 总分;
avg = sum/score.Length;
Console.Write("平均分是"+avg+",高于平均分的有:");//平均分;
//接下来是求高于平均分
for(int j = 0; j<score.Length;j++)
{
if(score[j]>avg)
{
Console.Write( name[j]+" " );
}
}
}