string[]names={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[]scores={"89","90","98","56","60","91","93","85"};
for(int i=0; i<scores.Length; i++)
{
int max=0;
int b=0;
if (scores[i]>max)
{
max= scores[i];
b=i;
Console.WriteLine("分数最高的是{0},分数是{1}",names[i],scores[i]);
}
}
string[,] result = new string[8, 2] { { "吴松", "89" }, { "钱东宇", "90" }, { "伏晨", "98" }, { "陈陆", "56" }, { "周蕊", "60" }, { "林日鹏", "91" }, { "何昆", "93" }, { "关欣", "85" } };
int x = int.Parse(result[0,1]),y;
for (int i = 0; i<result.GetLongLength(0);i++)
{
y=int.Parse(result[i,1]);
if (y > x)
{
x = y;
}
}
for (int j = 0; j < result.GetLongLength(0); j++)
{
y = int.Parse(result[j, 1]);
if (x == y)
{
string name=result[j,0];
Console.WriteLine("分数最高的是"+name+",分数是:"+x);
break;
}
}
可以转化再进行比较大小
例如string s=“123”;
int x=int.Parse(s);
声明scores 里面 int类型加了“ ”