class Program
{
static void Main(string[] args)
{
Sort s1 = new Sort();
while (true)
{
Console.WriteLine("请输入一组小于10位的数字,将会逆序打印");
s1.InputNum();
if (!s1.Judge()) break;
Console.WriteLine();
}
Console.ReadKey();
}
}
class Sort
{
//输入的方法
public void InputNum(){
//存储输入的字符串
string s = Console.ReadLine();
//存储转换后的数字
int i = 0;
//判断是不是数字串
bool isNum = false;
if (int.TryParse(s, out i))//将字符串转换成整数 返回布尔型 转换成功返回true 转换失败返回false
{
int nextNum = i;
int thisNum = 0;
Console.Write("输出结果是:");
for (int j = 0; j < s.Length; j++)
{
thisNum = nextNum % 10;
nextNum = nextNum / 10;
Console.Write(thisNum);
}
Console.WriteLine();
}
else {
Console.WriteLine("输入的不是一串数字");
}
}
//判断是否继续输入
public bool Judge()
{
Console.WriteLine("是否继续输入:(Y/N)");
string c = Console.ReadLine();
c = c.ToUpper();
if (c == "Y") {
return true;
}
else if (c == "N")
{
return false;
}
else {
Console.WriteLine("输入错误");
return false;
}
}
}