[C#] 纯文本查看 复制代码 double PingJun = 0, ZhuiDa = 0, PJJG;
Console.Write("输入几个数:");
int n = Convert.ToInt32(Console.ReadLine());
double[] a = new double[n];
for (int i = 0; i < n; i++)
{
Console.Write("输入第{0}个数:", i + 1);
a[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("第{0}个数为:{1}", i + 1, a[i]);
PingJun += a[i];
if (a[i] > ZhuiDa)
{
ZhuiDa = a[i];
}
}
PJJG = PingJun / n;
Console.Write("{0}个数为:\n", n);
for (int i = 0; i < n; i++)
{
if (i == n)
{
Console.WriteLine(a[i]);
}
else
{
Console.Write(a[i] + " ");
}
}
Console.WriteLine("{0}个数最大是{1},平均数为{2}", n, ZhuiDa, PJJG); |