namespace A._2._4数组排序和计算练习
{
class Program
{
static void Main(string[] args)
{
float x=0;
int[] a = new int[5];
Console.WriteLine("请输入五个整数,并用逗号分开:");
string s = Console.ReadLine();
string []str=s.Split (',');
for (int i = 0; i < str.Length; i++)
{
a[i] = Convert .ToInt32 (str[i]);
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if (a[i] >= a[j])
{
a[i] = a[j];
}
}
}
Console.Write("正序:");
for (int m = 0; m < 5; m++)
{
Console.Write(a[m]);
}
Console.Write("逆序:");
for (int m = 5; m > 0; m--)
{
Console.Write(a[m]);
}
for (int m = 5; m > 0; m--)
{
x = a[m] + x;
}
Console.WriteLine("最大值:{0}", a[5]);
Console.WriteLine("平均值为:" + x/5);
Console.ReadLine();
}
}
}
结果是这样的,剩下的最大值和平均值也没出来,求问