Cześć, przepisuję sobie z c++ na c# kod z "zgaduj zgadula" z kursu 4 c++ od Zelenta. Problem w tym że w konsoli, po wpisaniu drugiej liczby program mi się wysypuje.
Jestem początkująca, więc rozwiązanie może wydawać się banalne, ale na nie jeszcze nie wpadłam, ktoś ma pomysł?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace zgadywanka
{
class Program
{
static void Main(string[] args)
{
int choice;
Console.WriteLine(" I think about a number between 1 and 100,");
Random number = new Random();
int a = number.Next(1, 100);
Console.WriteLine(a);
Console.WriteLine("guess what number is it?");
do {
choice = Console.Read();
if (choice == a)
Console.WriteLine("Correct Number! Congratulations, You win");
else if (choice < a)
Console.WriteLine("It`s too little, try again!");
else if (choice > a)
Console.WriteLine("It`s too much, Try again!");
Console.Read();
return;
} while (choice == a);
}
}
}