using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string [,] score =new string [2,8]{{"吴松","钱东宇","付晨","陈陆","周蕊","林日鹏","何昆","关欣"},{"89","90","98","56","60","91","93","85"}};
int i=0;
for (int j=1;j<=8;j++)
{
if (String.Compare(score[1,j],score[1,i])>0)
i=j;
}
Console.Write("分数最高的是{0},分数是{1}",score[0,i],score[1,i]);
}
}
}
string[,] s = { { "吴松", "89" }, { "钱东宇", "90" }, { "伏晨", "98" }, { "陈陆", "56" }, { "周蕊", "60" }, { "林日鹏", "91" }, { "钱东宇", "90" }, { "何昆", "93" }, { "关欣", "85" } };
int max = 0;
for (int i = 2; i <s.Length / 2 ; i++)
{
if (i==2) {
if (int.Parse(s[0, 1]) < int.Parse(s[1, 1])) {
max = int.Parse(s[1, 1]);
}
else {
max = int.Parse(s[i, 1]);
}
}
if (int.Parse(s[i, 1]) < max)
{
max = max;
}
else {
max = int.Parse(s[i, 1]);
}
}
string name ="";
for (int y = 0; y < s.Length / 2 ; y++) {
if (int.Parse(s[y, 1]) == max)
{
name = s[y, 0];
}
}
Console.WriteLine("分数最高的是"+name+","+"分数是"+max);
你上面成绩也是定义的字符型,字符型不可以比较大小,你要是想比较大小就要把成绩转化成int,double,folat型