wigllytest

Untitled

Aug 7th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. string favorBook;
  9. getline(cin, favorBook);
  10.  
  11. int library;
  12. cin >> library;
  13.  
  14. int counter = 0;
  15. //bool bookIsFound = false;
  16.  
  17. string inputBook;
  18. getline(cin, inputBook);
  19.  
  20.  
  21. while (counter < library)
  22. {
  23. if (inputBook == favorBook)
  24. {
  25. // bookIsFound = true;
  26. break;
  27. }
  28.  
  29. counter++;
  30.  
  31. getline(cin, inputBook);
  32. }
  33.  
  34. if (inputBook == favorBook)
  35. {
  36. cout << "You checked " << counter -1 << " books and found it.";
  37. }
  38. else
  39. {
  40. cout << "The book you search is not here!" << endl;
  41. cout << "You checked " << counter << " books.";
  42. }
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment