string[] ming = new string[] {"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明" };
int[] fen = new int[]{90,65,88,70,46,81,100,68};
int pingjun;
pingjun = (fen[0] + fen[1] + fen[2] + fen[3] + fen[4] + fen[5] + fen[6] + fen[7])/8;
Console.WriteLine("平均分是{0},高于平均分的有:", pingjun);
string ren;
for (int i = 0; i < fen.Length; i++)
{
if (fen[i] > pingjun)
{
ren = ming[i];
Console.Write("{0}"+" ", ren);
}
}
你这个是对的啊,可以过的,我复制你的都过了。我给稍微改了下,毕竟手东加 太麻烦,不现实,学校有很多学生,一个一个太麻烦!
string[] ming = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明" };
int[] fen = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
int sum = 0,avg;//总分,平均分
string ren;
for (int i = 0; i < fen.Length; i++)
{
sum += fen[i];
// Console.WriteLine(sum);//查看总分是否正确
}
avg = sum / ming.Length;
Console.WriteLine("平均分是{0},高于平均分的有:", avg);
for (int i = 0; i < fen.Length; i++)
{
if (fen[i] > avg)
{
ren = ming[i];
Console.Write("{0}" + " ", ren);
}
}