NikaBang

ДЗ: Программа под паролем

Oct 8th, 2025 (edited)
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | Gaming | 0 0
  1. internal class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         string pasword = "smit777";
  6.         int triesCount = 3;
  7.         int numberOfErrors = 0;
  8.  
  9.         for (int i = 0; i < triesCount; i++)
  10.         {
  11.             Console.Write("Введите пароль: ");
  12.             string userInput = Console.ReadLine();
  13.  
  14.             if (userInput == pasword)
  15.             {
  16.                 Console.WriteLine("Ты молодец! Не сдавайся!");
  17.                 break;
  18.             }
  19.             else
  20.             {
  21.                 numberOfErrors++;
  22.                 Console.WriteLine("Не верный пароль!");
  23.             }
  24.         }
  25.  
  26.         if (numberOfErrors == triesCount)
  27.         {
  28.             Console.WriteLine("Ты истратил все попытки, давай до свидания!");
  29.         }
  30.  
  31.         Console.ReadKey();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment