用二维数组又做了一遍,有刚开始学习的加个好友吧,一起进步!
string[,] scores = { { "张一", "64" }, { "张二", "149" }, { "张三", "50" }, { "张四", "80" }, { "张五", "99" } };
string name = null, topName = null;
int score = 0;
int topScore = 0;
for (int i = 0; i <scores.GetLongLength(0); i++)
{
name=scores[i,0];
score = int.Parse(scores[i,1]);
if (score>topScore)
{
topScore = score;
topName = name;
}
}
Console.WriteLine("最高得分是:{0},分数是:{1}",topName,topScore);
Console.ReadKey();