using System;
using System.Collections.Generic;
using System.Text;
namespace inputCapitalLetter
{
class Program
{
static void Main()
{
bool ok = false;
while (ok == false)
{
Console.Write("请输入5个大写字母:");
string str = Console.ReadLine();
if (str.Length != 5)
{
Console.WriteLine("你输入的字符个数不是5个,请重新输入。");
}
else
{
ok = true;
for (int i = 0; i < 5; i++)
{
char c = str[i];
if (c < 'A' || c > 'Z')
{
Console.WriteLine("第{0}个字符“{1}”不是大写字母,请重新输入。", i + 1, c);
ok = false;
break;
}
}
}
}
}
}
}
编写一个控制台应用程序,要求用户输入5个大写字母,如果用户输入的信息不满足要求,提示帮助信息并要求重新输入
最新推荐文章于 2021-02-19 11:55:11 发布