Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string favouriteBook;
- int totalBooksCount;
- getline(cin, favouriteBook);
- cin >> totalBooksCount;
- cin.ignore();
- int currentBookCount = 0;
- bool bookIsFound = false;
- while (currentBookCount < totalBooksCount) {
- string currentBookName;
- getline(cin, currentBookName);
- if (currentBookName == favouriteBook) {
- bookIsFound = true;
- break;
- }
- currentBookCount++;
- }
- if (bookIsFound) {
- cout << "You checked " << currentBookCount << " books and found it.";
- }
- else {
- cout << "The book you search is not here!" << endl << "You checked " << currentBookCount << " books.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment