Anzzhhela98

dd

Jul 7th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3.  
  4. namespace Библиотека___2
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string needBooks = Console.ReadLine();
  11.             int availableBoks = int.Parse(Console.ReadLine());
  12.  
  13.             int checkedBooks = 0;
  14.             while (availableBoks > 0)
  15.             {
  16.                 string giveBooks = Console.ReadLine();
  17.  
  18.                 if (needBooks == giveBooks)
  19.                 {
  20.                     Console.WriteLine($"You checked {checkedBooks} books and found it.");
  21.                     break;
  22.                 }
  23.                 else
  24.                 {
  25.                     checkedBooks++;
  26.                 }
  27.                 availableBoks--;
  28.             }
  29.             if (availableBoks <= 0)
  30.             {
  31.                 Console.WriteLine("The book you search is not here.");
  32.                 Console.WriteLine($"You checked {checkedBooks} books.");
  33.             }
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment