namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
int[]num=new int[]{89,90,98,56,60,91,93,85};
string[] xingming = new string[] {"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int max=num[0];
string name=xingming[0];
for(int i=0;i<num.Length;i++)
{
if(num[i]>max)
max=num[i];
name=xingming[i];
}
Console.Write("分数最高的是{0},分数是{1}",name,max);
}
}
}
if(num[i]>max)
max=num[i];
name=xingming[i];
if下面两条语句要用{}括起来,确保两条语句都是受if条件限制,否则只有if下面第一句是受if条件限制的,第二句话会一直执行到for循环最后一次