Advertisement
Legiomax

C#_2_lesson_programm_under_password

Jan 10th, 2024
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | Software | 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 C_Ijun
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string passwordForMessage = "i'll be back";
  14.             string userMessage;
  15.  
  16.             int tryCount = 3;
  17.  
  18.             for (int i = 1; i <= tryCount; i++)
  19.             {
  20.                 Console.Write("Введите пароль: ");
  21.                 userMessage = Console.ReadLine();
  22.  
  23.                 if (passwordForMessage == userMessage)
  24.                 {
  25.                     Console.WriteLine("Всё в порядке! Свои.");
  26.                     break;
  27.                 }
  28.                 else
  29.                 {
  30.                     Console.WriteLine($"Не верно, осталось {tryCount - i} попыток.");
  31.                 }
  32.             }
  33.  
  34.             Console.WriteLine("Это конец...");
  35.             Console.ReadLine();
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement