Krasimir_Slavov

Untitled

Oct 7th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 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 While_Old_Books
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string book = Console.ReadLine();
  14. var capacity = int.Parse(Console.ReadLine());
  15.  
  16. int count = 0;
  17. string input = Console.ReadLine();
  18.  
  19. while (capacity-- > 0)
  20. {
  21. if (book == input)
  22. {
  23. Console.WriteLine($"You checked {count} books and found it.");
  24. return;
  25. }
  26. count++;
  27. input = Console.ReadLine();
  28. }
  29. Console.WriteLine($"The book you search is not here!");
  30. Console.WriteLine($"You checked {count} books.");
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment