Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save smah-beep/5088fa74a10f105cc56a1367a6c1ff8e to your computer and use it in GitHub Desktop.

Select an option

Save smah-beep/5088fa74a10f105cc56a1367a6c1ff8e to your computer and use it in GitHub Desktop.
ДЗ: Контроль выхода
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _DZ_
{
internal class Program
{
static void Main(string[] args)
{
Random rand = new Random();
string stopWord = "exit";
string userWord;
int composition;
while (true)
{
int multiplier1 = rand.Next(1, 89), multiplier2 = rand.Next(3, 54);
composition = multiplier1 * multiplier2;
Console.WriteLine(composition);
Console.WriteLine("Пока вы не напишете слово 'exit', программа будет перемножать разные числа между собой");
Console.Write("Введите слово: ");
userWord = Console.ReadLine();
if (userWord == stopWord)
{
Console.WriteLine("Программа закончила свою работу и больше не будет перемножать числа");
break;
}
else if (userWord != stopWord)
{
Console.WriteLine("Слово введено неверно!");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment