using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApptest1
{
class Program
{
static void Main(string[] args)
{
int x=0;
string[,] arr={{"吴松","89"},{"钱东宇","90"},{"伏晨","98"},{"陈陆","56"},{"周蕊","60"},{"林日鹏","91"},{"何昆","93"},{"关欣","85"}};
int max = Convert.ToInt32(arr[1, 0]); //把吴松的89设为最高分 分数max因为是int类型所以要转换
for(int i=0;i<arr.GetLength(0);i++)
{
if (max < Convert.ToInt32(arr[i, 1]))
{
max = Convert.ToInt32(arr[i, 1]);
x=i;
}
}
Console.Write("分数最高的是{0},分数是{1}", arr[x,0], arr[x,1]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApptest1
{
class Program
{
static void Main(string[] args)
{
int x=0;
string[,] arr=new string[,]={{"吴松","89"},{"钱东宇","90"},{"伏晨","98"},{"陈陆","56"},{"周蕊","60"},{"林日鹏","91"},{"何昆","93"},{"关欣","85"}};
int max = Convert.ToInt32(arr[0, 1]); //把吴松的89设为最高分 分数max因为是int类型所以要转换
for(int i=0;i<arr.GetLongLength(0);i++)
{
if (max < Convert.ToInt32(arr[i, 1]))
{
max = Convert.ToInt32(arr[i, 1]);
x=i;
}
}
Console.Write("分数最高的是{0},分数是{1}", arr[x,0], arr[x,1]);
}
}
}
已解决.
x是用来储存最高分的索引的