qq_慕沐3064214
2019-09-08 22:05
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
string[,] score={{"景珍","90"},{"林惠洋","65"},{"成蓉","88"},{"洪南昌","70"},{"龙玉民","46"},{"单江开","81"},{"田武山","100"},{"王三明","68"}};
int sum=0,avg;
for(int i=0;i<score.GetLongLength(0);i++)
{
sum +=int.Parse(score[i,1]);
}
avg=sum/score.GetLength(0);
Console.WriteLine("平均分是{0},高于平均分的有:",avg);
for(int x=0;x<score.GetLongLength(0);x++)
{
if(int.Parse(score[x,1])> avg)
Console.Write(score[0,x]+" ");
}
}
}
}
Console.Write(score[0,x]+" ");
二维数组的上标超了,应该改为Console.Write(score[x,0]+" ");
C#开发轻松入门
254118 学习 · 1459 问题
相似问题