回覆列表
  • 1 # lkmmy2351

    這是我寫的語句:static void Main(string[] args){Random d = new Random();int num = d.Next(1, 100);//隨機數int num1 = 0;//用來儲存輸入的數Console.WriteLine("輸入一個數");while (true){string str = Console.ReadLine();int.TryParse(str, out num1);if (num1 == 0){Console.WriteLine("輸入有誤,重新輸入");continue;}else{if (num1 > num){Console.WriteLine("數字大了,重新輸入");continue;}else if (num1 < num){Console.WriteLine("數字小了,重新輸入");continue;}else if (num1 == num){Console.WriteLine("正確");break;}}}Console.Read();}

  • 2 # 使用者3937226028394

    這是我寫的語句:

    static void Main(string[] args)

    {

    Random d = new Random();

    int num = d.Next(1, 100);//隨機數

    int num1 = 0;//用來儲存輸入的數

    Console.WriteLine("輸入一個數");

    while (true)

    {

    string str = Console.ReadLine();

    int.TryParse(str, out num1);

    if (num1 == 0)

    {

    Console.WriteLine("輸入有誤,重新輸入");

    continue;

    }

    else

    {

    if (num1 > num)

    {

    Console.WriteLine("數字大了,重新輸入");

    continue;

    }

    else if (num1

    {

    Console.WriteLine("數字小了,重新輸入");

    continue;

    }

    else if (num1 == num)

    {

    Console.WriteLine("正確");

    break;

    }

    }

    }

    Console.Read();

    }

  • 中秋節和大豐收的關聯?
  • 書協副主席何奇耶徒,寫的到底是醜書,還是蒙古書法?