卡在无限循环C#中(while循环)

时间:2019-11-09 16:19:12

标签: c# text while-loop do-while

大家好,我是编程新手,只是学习了一些基础知识,所以如果有人可以帮助我解决这个问题,我将陷入无限循环之中

Console.WriteLine("Welcome to the game guess the word");
        Console.WriteLine("First word will be:");
        Console.Write("City located in Europe in EX Yugoslavia is:");
        string userWordInput = Console.ReadLine();
        int i = 0;
        do
        {

            for ( i = 0; i < 5; i++)
            {
                Console.WriteLine("Your input is wrong");
            }

        } while (userWordInput!="Sarajevo");

        Console.ReadLine();

1 个答案:

答案 0 :(得分:0)

Console.WriteLine("Welcome to the game guess the word");
Console.WriteLine("First word will be:");
Console.Write("City located in Europe in EX Yugoslavia is:");
string userWordInput = Console.ReadLine();
int i = 0;
do
{
    for (i = 0; i < 5; i++)
    {
        Console.WriteLine("Your input is wrong");
    }
} while (Console.ReadLine() != "Sarajevo");