using System;
using System.Collections.Generic;
using System.Text;
namespace KnowledgePoint
{
class _19_Ex_For
{
static void Main(string[] args)
{
int[] ageArr = new int[5]; // 定义年龄数组
int times = 1; // 定义计次标识
for (int i = 0; i < ageArr.Length; i++)
{
try
{
Console.Write("请输入第" + (i + 1) + "个人的年龄:");
int age = Convert.ToInt32(Console.ReadLine());
if (age >= 0 && age <= 100)
{
ageArr[i] = age;
}
else
{
Console.WriteLine("\n提示:年龄输入与正常的现实年龄不符!程序运行结束!");
break;
} // 年龄区间判断结束
}
catch
{
C#接收5个年龄和计算平均年龄
最新推荐文章于 2023-07-04 15:43:16 发布
using System;using System.Collections.Generic;using System.Text;namespace KnowledgePoint{ class _19_Ex_For { static void Main(string[] args) { int[] ageArr = new int[5]; // 定义年龄数组 int times = 1; // 定义计次标
摘要由CSDN通过智能技术生成