比較大小的時候報錯說超出數(shù)組范圍了
for(int i = 0 ;i < score.Length ;i++) ? ? ? ? ? ?{ ? ? ? ? ? ? ? ?if(int.Parse(score[j,1]) < int.Parse(score[i,1])) ? ? ? ? ? ? ? ?{ ? ? ? ? ? ? ? ? ? ?j = i; ? ? ? ? ? ? ? ?} ? ? ? ? ? ?} ? ? ? ? ? ? 為什么報錯說超出數(shù)組范圍了?
for(int i = 0 ;i < score.Length ;i++) ? ? ? ? ? ?{ ? ? ? ? ? ? ? ?if(int.Parse(score[j,1]) < int.Parse(score[i,1])) ? ? ? ? ? ? ? ?{ ? ? ? ? ? ? ? ? ? ?j = i; ? ? ? ? ? ? ? ?} ? ? ? ? ? ?} ? ? ? ? ? ? 為什么報錯說超出數(shù)組范圍了?
2019-10-15
舉報
2019-10-22
static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[,] name_score = {
? ? ? ? ? ? ? ? {"吳松", "89"},?
? ? ? ? ? ? ? ? {"錢東宇", "90"},
? ? ? ? ? ? ? ? {"伏晨", "98"},
? ? ? ? ? ? ? ? {"陳陸", "56"},
? ? ? ? ? ? ? ? {"周蕊", "60"},
? ? ? ? ? ? ? ? {"林日鵬", "91"},
? ? ? ? ? ? ? ? {"何昆", "93"},
? ? ? ? ? ? ? ? {"關欣", "85"}
? ? ? ? ? ? };
? ? ? ? ? ? string[,] temp = {{"", ""}};
? ? ? ? ? ? for(int x = 0, _max = 0; x < name_score.GetLength(0); x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int scp = int.Parse(name_score[x, 1]);
? ? ? ? ? ? ? ? if(_max < scp)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? _max = scp;
? ? ? ? ? ? ? ? ? ? temp[0,0] = name_score[x, 0];
? ? ? ? ? ? ? ? ? ? temp[0,1] = name_score[x, 1];
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.Write("分數(shù)最高的是{0},分數(shù)是{1}", temp[0, 0], temp[0, 1]);
? ? ? ? }
2019-10-15
數(shù)組元素是8個,長度是16