为什么这串代码执行不了?目的是为了挑出最大值。
static void Main(string[] args)
{
int N=0;
int[]score={89,90,98,56,60,91,93,85};
string[]name={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
for (int i=0;i<score.Length;i++)
if N<score[i]
{
N=i;
}
Console.WriteLine("分数最高的是{0},分数是{1}",name[N],score[N]);
}
static void Main(string[] args)
{
int[] score={89,90,98,56,60,91,93,85};
string[] name={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int N=score[0];//假设第一个分是最高分
for (int i=1; i<score.Length; i++)
{
if (N < score[i])
{
N=score[i];
}
}
Console.WriteLine("分数最高是{0}",N);
}
这是求最大值的方法,,这是我的拙见。。。。。
有人么?