int[] fs= new int[4];
string[] name = new string[4];
int max = fs[0];
string maxname=null;
for (int i=0;i<name.Length;i++)
{
Console.WriteLine("请输入第" +(i+1) + "位学生的姓名");
name[i]=Console.ReadLine();
Console.WriteLine("请输入第" +(i+1) + "位学生的成绩");
fs[i]=int.Parse(Console.ReadLine());
if (fs[i] > max)
{
max = fs[i];
maxname = name[i];
}
}
Console.WriteLine("最大值是:" + max + "人是" + maxname);
int sum = 0, avg=0;
for(int j=0;j<fs.Length;j++)
{
sum = sum + fs[j];
avg = sum / fs.Length;
if (fs[j]>avg)
Console.WriteLine( name[j]);
}
int[] fs = new int[4];
string[] name = new string[4];
int max = fs[0];
string maxname = null;
int sum = 0;
for (int i = 0; i < name.Length; i++)
{
Console.WriteLine("请输入第" + (i + 1) + "位学生的姓名");
name[i] = Console.ReadLine();
Console.WriteLine("请输入第" + (i + 1) + "位学生的成绩");
fs[i] = int.Parse(Console.ReadLine());
if (fs[i] > max)
{
max = fs[i];
maxname = name[i];
}
sum = sum + fs[i];
}
Console.WriteLine("最大值是:" + max + "人是" + maxname);
int avg;
avg = sum / fs.Length;
Console.WriteLine("平均分是{0},高于平均分的有",avg);
for (int j = 0; j < fs.Length; j++)
{
if (fs[j] > avg)
{
Console.WriteLine(name[j]+" ");
}
}
//sum要放在第一个循环里,avg放在循环的外面,不然就是sum的第一个总值被除,而不是全部被除。
再缕缕思路