Advertisement
SnowPhoenix347

2.8

Oct 27th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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.  
  8.  
  9. namespace Cslight15
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string password, enteredPassword, message;
  16.             bool checkPassword;
  17.             int counter = 0;
  18.  
  19.             message = "Секретное сообщение";
  20.  
  21.             Console.Write("Создайте пароль: ");
  22.             password = Console.ReadLine();
  23.  
  24.             Console.Write("Введите пароль: ");
  25.  
  26.  
  27.             while (counter < 5)
  28.             {
  29.                 enteredPassword = Console.ReadLine();
  30.                 checkPassword = password == enteredPassword;
  31.                 if (checkPassword)
  32.                 {
  33.                     Console.WriteLine(message);
  34.                 }
  35.                 else if (!checkPassword)
  36.                 {
  37.                     Console.Write("Повторите попытку: ");
  38.                     counter++;
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement