Advertisement
rukvir

HW 2_8_1

Apr 30th, 2022
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 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 HomeWorck_2_8_1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string userPassword;
  14.             string mainPassword = "321123";
  15.             string secretMessage = "Ты взломал это ШИФР!!!";
  16.             int hackingAttempts = 3;
  17.            
  18.             Console.Write("Введите пароль - ");
  19.             for (int counter = 0; counter < hackingAttempts; counter++)
  20.             {
  21.                 userPassword = Console.ReadLine();
  22.                 if (userPassword == mainPassword){
  23.                     Console.WriteLine(secretMessage);
  24.                 }
  25.                 else{
  26.                     Console.WriteLine($"Пароль не верный! Осталось попыток - {hackingAttempts - counter - 1}");
  27.                 }
  28.             }
  29.  
  30.            
  31.             Console.ReadKey();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement