| 景珍 | 林惠洋 | 成蓉 | 洪南昌 | 龙玉民 | 单江开 | 田武山 | 王三明 |
|---|---|---|---|---|---|---|---|
| 90 | 65 | 88 | 70 | 46 | 81 | 100 | 68 |
上面是一些同学的姓名和对应的考试分数,请输出他们的平均分和高于平均分的同学姓名。输出结果如下:
平均分是76,高于平均分的有:
景珍 成蓉 单江开 田武山
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
int mean = 0;
int [] scores = new int[]
{
90,65,88,70,46,81,100,68
};
string [] names = new string[]
{
"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"
};
foreach(int x in scores)
{
mean = mean + x;
}
mean = mean / scores.Length;
Console.WriteLine("平均分是{0},高于平均分的有:",mean);
for (int i=0; i<scores.Length;i++)
{
if (scores[i]>=mean)
{
Console.Write("{0} ",names[i]);
}
}
}
}
}
发表评论