标签:
Console.Write("人数:");
int n = int.Parse(Console.ReadLine());
int[] nianling = new int[n];
int max = 0, min = 0, sum = 0;
for (int i = 0; i < n; i++)
{
Console.Write("第{0}个人的年龄为:", i + 1);
nianling[i] = int.Parse(Console.ReadLine());
sum = sum + nianling[i];
if (i == 0)
{
max = nianling[i];
min = nianling[i];
}
if (max < nianling[i])
{
max = nianling[i];
}
if (min > nianling[i])
{
min = nianling[i];
}
}
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (nianling[j] > nianling[i])
{
int zhong = nianling[j];
nianling[j] = nianling[i];
nianling[i] = zhong;
}
}
}
foreach (int a in nianling)
{
Console.Write(a + " ");
}
Console.Write("\n");
Console.WriteLine(max);
Console.WriteLine(min);
Console.WriteLine(sum / n);
标签:
原文地址:http://www.cnblogs.com/lz123/p/4940458.html