为什么只能打印出一个名字?
语法没有问题,但是只能打印出平均分和“景珍”这个名字
string[,] score = new string[,] { {"景珍","90"}, {"林惠洋", "65" }, {"洪南昌","70" }, { "龙玉民", "46" },
{ "单江开", "81" }, { "田武山", "100" }, { "王三明", "68" }};
float sum = 0;
float avg = 0;
for ( int i = 0;i < score.GetLongLength(1);i++ )
{
sum += Convert.ToInt64(score[i, 1]);
}
avg = sum / score.GetLongLength(1);
Console.WriteLine("平均分是{0}", avg);
for (int i = 0; i < score.GetLongLength(1); i++)
{
if (avg< float.Parse(score[i, 1]))
{
Console.WriteLine("高于平均分的有:"+score[i,0]);
}
}