Advertisement
Vadim_Rogulev

Untitled

Apr 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 Программа_под_паролем
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int i = 5;
  14.             string Password = "Qw123456";
  15.             string Pas = "";
  16.             while (i != 0)
  17.             {
  18.                 Console.WriteLine("Введите пароль");
  19.                 while (true)
  20.                 {
  21.                     ConsoleKeyInfo CharKey = Console.ReadKey(true);
  22.                     if (CharKey.Key == ConsoleKey.Enter)
  23.                     {
  24.                         Console.Write("\n");
  25.                         break;
  26.                     }
  27.                     else if (CharKey.Key == ConsoleKey.Backspace)
  28.                     {
  29.                         Pas = Pas.Remove(Pas.Length - 1);
  30.                         Console.Write("\b \b");
  31.                     }
  32.                     else
  33.                     {
  34.                         Pas += CharKey.KeyChar;
  35.                         Console.Write("*");
  36.                     }
  37.                 }
  38.                 if (Password == Pas)
  39.                 {
  40.                     Console.Clear();
  41.                     Console.Write("Пароль Верен!");
  42.                     Console.ReadKey();
  43.                     Console.Write("Красава! ^_^\n");
  44.                     Console.ReadKey();
  45.                     return;
  46.  
  47.                 }
  48.                 else
  49.                 {
  50.                     Console.Clear();
  51.                     Console.WriteLine("Не верный пароль!");
  52.                     i--;
  53.                     Console.WriteLine($"Попыток осталось {i}");
  54.                     Console.ReadKey();
  55.                 }
  56.             }
  57.             Console.WriteLine(Password);
  58.         }
  59.        
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement