Advertisement
Torgach

Контроль выхода

Aug 11th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp5
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Программа выводит поочередно числа до тех пор, пока вы не напишите ключевое слово < exit >");
  10.             int attemptСounter = 0;
  11.             string exit = "exit";
  12.             string userInput;
  13.             bool able = true;
  14.             while (able)
  15.             {
  16.                 Console.WriteLine("Введите ключевое слово: ");
  17.                 userInput = Console.ReadLine();
  18.                 if (exit == userInput)
  19.                 {
  20.                     Console.WriteLine("Вы вышли из цикла");
  21.                     break;
  22.                 }
  23.                 else
  24.                 {
  25.                     Console.WriteLine("Продолжаем считать...");
  26.                     attemptСounter++;
  27.                     Console.WriteLine(attemptСounter);
  28.                 }
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement