新手只能寫成這樣了,不知道怎么用二維數(shù)組寫?
static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string [] names ={"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關欣"};
? ? ? ? ? ? int [] score ={89,90,98,56,60,91,93,85};
? ? ? ? ? ? int maxpeople = 0;
? ? ? ? ? ? int maxscore = 0;
? ? ? ? ? ? for(int i = 0 ;i<score.Length;i++){
? ? ? ? ? ? ? ? if (score[i]>maxscore){
? ? ? ? ? ? ? ? ? ? maxscore = score[i];
? ? ? ? ? ? ? ? ? ? maxpeople = i;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.Write("分數(shù)最高的是"+names[maxpeople]+",分數(shù)是"+score[maxpeople]);
? ? ? ? }
2017-09-28
并不能 強類型語言 數(shù)組內類型必須一致
2017-12-05
??????????? string[,] test = new string[8, 2] { { "吳松", "89" }, { "錢東宇", "90" }, { "伏晨", "98" }, { "陳璐", "56" }, { "周蕊", "60" }, { "林日鵬", "91" }, { "何坤", "93" }, { "關欣", "85" } };
??????????? int a = 0 , ii = 0;
??????????? string b = "";
??????????????? for (int i = 0; i < test.GetLongLength(0); i++)
??????????????? {
??????????????????? if (Convert.ToInt32(test[i, 1]) > a)
??????????????????? {
??????????????????????? //Console.WriteLine(test[i, 1]);
??????????????????????? a = Convert.ToInt32(test[i, 1]);
??????????????????????? b = test[i, 0];
??????????????????????? ii = i;
??????????????????? }
??????????????? }
??????????? Console.WriteLine(a);
??????????? Console.WriteLine(b);
??????????? Console.WriteLine(ii);