主题:新手入门
/*编写一个应用程序,让用户输入两个数字,并显示它们,但拒绝接受两个数字都大于10的情况.*
* 我的代码如下,在必须使用goto语句的情况下,怎样才能达到题目所定的要求*/
using System;
namespace Judge
{
class Judge
{
static void Main(string[] args)
{
int number1=0,number2=0;
Console.WriteLine("Enter First Number:");
number1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
number2=Convert.ToInt32(Console.ReadLine());
if(number1>10 && number2>10)
{
goto MyJudge;
}
Console.WriteLine("number:{0}{1}",number1,number2);
MyJudge:
Console.WriteLine("Enter First Number:");
number1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
number2=Convert.ToInt32(Console.ReadLine());
}
}
}
* 我的代码如下,在必须使用goto语句的情况下,怎样才能达到题目所定的要求*/
using System;
namespace Judge
{
class Judge
{
static void Main(string[] args)
{
int number1=0,number2=0;
Console.WriteLine("Enter First Number:");
number1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
number2=Convert.ToInt32(Console.ReadLine());
if(number1>10 && number2>10)
{
goto MyJudge;
}
Console.WriteLine("number:{0}{1}",number1,number2);
MyJudge:
Console.WriteLine("Enter First Number:");
number1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
number2=Convert.ToInt32(Console.ReadLine());
}
}
}