int [] fs=new int[8]{90,65,88,70,46,81,100,68};
string [] nam=new string[8]{"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};
double avg;
avg=0;
int sum;
sum=0;
for(int i=0;i<fs.length;i++)
{
sum+=fs[i];
}
avg=sum/fs.length;
Console.Write("平均分是{0},高于平均分的有:",avg);
Console.WriteLine();
for(int j=0;j<fs.length;j++)
{
if (avg<double.parse(fs[j]))
Console.Write(nam[j]+" ");
}
帮你修改好了,下面是正确的代码
int[] fs = new int[8] { 90, 65, 88, 70, 46, 81, 100, 68 };
string[] nam = new string[8] { "景珍", "林惠洋", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明" };
double avg;
avg = 0;
int sum;
sum = 0;
for (int i = 0; i < fs.Length; i++) //注意是Length而不是length,大小写错了,你的Length一直都小写了
{
sum += fs[i];
}
avg = sum / fs.Length;
Console.Write("平均分是{0},高于平均分的有:", avg);
Console.WriteLine();
for (int j = 0; j < fs.Length; j++)
{
if (avg < fs[j]) //fs和avg都属于数字类型,一个double,一个是int,可以直接用比较,不需要转换类型
Console.Write(nam[j] + " ");
}