string [,]nScore=new[,]{{"吴松","89"},{"钱东宇","90"},{"伏晨","98"},{"陈陆","56"},{"周蕊","60"},{"林日鹏","91"},{"何昆","93"},{"关欣","85"}};
string name="";
int maxScore=0;
for (int i=0; i<nScore.GetLength(0);i++)
{
if (maxScore<Convert.ToInt32(nScore[i,1]))
{
maxScore=Convert.ToInt32(nScore[i,1]);
name=nScore[i,0];
}
}
Console.WriteLine("分数最高的是{0},分数是{1}",name,maxScore);
运行结果意思是对的,结果有误是你的标点格式与答案不一样,你换成中文逗号就可以了
是对的,没问题
string[,] test = new string[8, 2] { { "吴松", "89" }, { "钱东宇", "90" }, { "伏晨", "98" }, { "陈陆", "56" }, { "周蕊", "60" }, { "林日鹏", "91" }, { "何昆", "93" }, { "关欣", "85" } };
int max = 0, m = 0;
for (int i = 0; i < test.GetLongLength(0); i++)
{
int n = Convert.ToInt16(test[i, 1]);
if (n >= max)
{
max = n;
m = i;
}
}
Console.WriteLine("分数最高的是{0},分数是{1}。", test[m, 0], test[m, 1]);