Advertisement
TravaMan

Basic_Task9

Nov 29th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Basic_Task9
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string password = "123456";
  10.             string str = "";
  11.             int attempts = 0;
  12.            
  13.             while (str != "123456" && attempts != 3)
  14.             {
  15.                 Console.WriteLine("Введите пароль: ");
  16.                 str = Console.ReadLine();
  17.                
  18.                 if (str == password)
  19.                 {
  20.                     Console.WriteLine("Ответ: 42");
  21.                 }
  22.                 else
  23.                 {
  24.                     Console.Write("Пароль неверный. ");
  25.                     attempts++;
  26.                    
  27.                     if (attempts != 3)
  28.                     {
  29.                         Console.WriteLine("Попробуйте еще раз.");
  30.                     }
  31.                 }
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement