Advertisement
nikolayneykov

Untitled

Oct 7th, 2018
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2.  
  3. class OldBooks
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string bookName = Console.ReadLine();
  8.         int libraryCapacity = int.Parse(Console.ReadLine());
  9.         int checkedBooksCount = 0;
  10.         string input = string.Empty;
  11.         while (checkedBooksCount < libraryCapacity && (input = Console.ReadLine()) != bookName)
  12.         {
  13.             checkedBooksCount++;
  14.         }
  15.         Console.WriteLine(input == bookName ?
  16.             $"You checked {checkedBooksCount} books and found it." :
  17.             $"The book you search is not here!\nYou checked {checkedBooksCount} books.");
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement