namespace test
{
class Program
{
static void Main(string[] args)
{
string[] name = { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
int[]score = { 89, 90, 98, 56, 60, 91, 93, 85 };
int t = 0;
string r = "";
for (int i = 0; i < score.Length; i++)
{
if (score[i] > t)
t = score[i];
r = name[i];
}
Console.WriteLine("分数最高的是-" + r + "," );
Console.WriteLine("分数是-" + t);
}
}
}
max 不是关键字,用到max 是因为要查找最高分啊
代码供参考
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string[]names={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[]score={89,90,98,56,60,91,93,88};
int max=0;
int n=0;
for(int i=0;i<score.Length;i++)
{
if(score[i]>max)
{
max=score[i];
}
else
{
continue;
}
n=i;
}
Console.WriteLine("分数最高的是{0},分数是{1}",names[n],score[n]);
}
}
}