慕妹8829832
2019-10-15 09:58
for(int i = 0 ;i < score.Length ;i++) { if(int.Parse(score[j,1]) < int.Parse(score[i,1])) { j = i; } } 为什么报错说超出数组范围了?
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("分数最高的是{0},分数是{1}", temp[0, 0], temp[0, 1]);
}
数组元素是8个,长度是16
C#开发轻松入门
254118 学习 · 1459 问题
相似问题