Advertisement
aggressiveviking

Untitled

Feb 10th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01._Old_Books
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string bookName = Console.ReadLine();
  10. int bookCount = int.Parse(Console.ReadLine());
  11.  
  12. string currentBookName = Console.ReadLine();
  13. int counter = 0;
  14.  
  15. while (bookName != currentBookName)
  16. {
  17. counter++;
  18.  
  19. if (counter == bookCount)
  20. {
  21. break;
  22. }
  23.  
  24. currentBookName = Console.ReadLine();
  25. }
  26.  
  27. if (bookName == currentBookName)
  28. {
  29. Console.WriteLine($"You checked {counter} books and found it.");
  30. }
  31. else
  32. {
  33. Console.WriteLine("The book you search is not here!");
  34. Console.WriteLine($"You checked {counter} books.");
  35. }
  36.  
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement