using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters;
class All
{
class program
{
static void Main(string[] args)
{
int[] num = new int[10];
for (int i = 0; i < 10; i++)
{
Console.Write("请输入第");
Console.Write(i);
Console.Write("个字符:");
string str= Console.ReadLine();
//Console.WriteLine();
bool decision = true;
for(int j=0;j<str.Length;j++)
{
if (str[j] < 48 || str[j] > 57)
{
decision = false;
break;
}
}
if (!decision)
{
i--;
Console.WriteLine("请输入数字");
}
else num[i] = int.Parse(str);
}
Console.Write("平均数是");
Console.Write(num.Average());
}
}
}
输入十个数字求平均数
最新推荐文章于 2024-11-02 04:24:32 发布