用二維數組又做了一遍,有剛開始學習的加個好友吧,一起進步!
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();
2018-11-01
其實根本不需要name和score變量的,只要topname和topscore就好了
2018-10-14
厲害啊 大神