Pętla mi się non stop kręci

0

Proszę o sprawdzenie kodu. Jak podaję liczbę za duzą lub za małą to się non stop pętla kręci. a przy podaniu dobrej jest ok.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("podaj imie");
            string imie;
            string l;
            imie = Console.ReadLine();
            Console.WriteLine("podaj liczbę do której losować");
            Convert.ToUInt32(l = Console.ReadLine());

            Random Oran = new Random();
            Int32 x = Oran.Next(Convert.ToInt32(l));
            Console.WriteLine(x);
            Int32 li;
            Console.WriteLine("podaj swoją liczbę " + imie);
            li = Convert.ToInt32(Console.ReadLine());


            do
            {


                if (Convert.ToInt32(li) > Convert.ToInt32(x))
                {
                    Console.WriteLine("Twoja liczba jest za duża " + li);
                }


                else

                    if (li == x)
                    {
                        Console.WriteLine("To moja liczba " + imie + " Wygrałeś");
                    }





                    else
                    
                        if (li < x)
                        {
                            Console.WriteLine("Twoja liczba jest za mała" + li);
                    }







            }
            while (li != x);
            
              
             
            Console.WriteLine("koniec");
            Console.ReadLine();

        }
    }
}
0
  1. Kod do znaczników! Nauczcie się wreszcie, że wszędzie może być burdel, ale kod ma być ubrany w znaczniki bo jest ładnie.
  2. Zrób to w pętli while, tam też ustaw warunek.
  3. Spróbuj pousuwać else.
0

Dżizas...

                if (Convert.ToInt32(li) > Convert.ToInt32(x))
                 {
                     Console.WriteLine("Twoja liczba jest za duża " + li);
                 }

Wywalasz komunikat a nic nie robisz z liczbą...

0

Sorry można już skasować. zauważyłem to dopiero jak krok po kroku odpaliłem program. Ale plama.

1 użytkowników online, w tym zalogowanych: 0, gości: 1