CrewLab

Untitled

May 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace day_00
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string pass;
  14.             int counter;
  15.  
  16.             counter = 5;
  17.             Console.Write("Введите пароль: ");
  18.             pass = Console.ReadLine();
  19.             while(counter > 0)
  20.             {
  21.                 if (counter == 5)
  22.                 {
  23.                     Console.Write("\nПожалуйста, повторите ваш пароль, у вас есть " + counter + " попыток: ");
  24.                     if (pass == Console.ReadLine())
  25.                     {
  26.                         Console.Write("Пароль верен! Вы можете прочитать секретное сообщение:\n\"Улыбнись, ты классный!\"\n");
  27.                         break;
  28.                     }
  29.                 }
  30.                 else if (counter < 5)
  31.                 {
  32.                     Console.Write("\nПароль не верен! У вас осталось " + counter + " попытки. Пожалуйста, повторите ваш пароль: ");
  33.                     if (pass == Console.ReadLine())
  34.                     {
  35.                         Console.Write("Пароль верен! Вы можете прочитать секретное сообщение:\n\"Улыбнись, ты классный!\"\n");
  36.                         break;
  37.                     }
  38.                 }
  39.                 else if(counter == 1)
  40.                     Console.WriteLine("\nСожалею, у вас больше не осталось попыток!");
  41.                 counter--;
  42.  
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment