Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // FirstProgramm.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <iomanip>
  6. #include <iostream>
  7.  
  8. using std::cout;
  9. using std::cin;
  10. using std::endl;
  11. using std::string;
  12.  
  13.  
  14.  
  15.  
  16. using std::setprecision;
  17. using std::fixed;
  18.  
  19.  
  20. int main()
  21. {
  22. char book[256];
  23. int books;
  24. int count = 0;
  25. bool doesExist = false;
  26.  
  27. cin.getline(book, 256);
  28. cin >> books;
  29.  
  30. cin.ignore();
  31. cout;
  32.  
  33. while (books > 0)
  34. {
  35.  
  36. char checkedBook[256];
  37. cin.getline(checkedBook, 256);
  38.  
  39. if (checkedBook == book)
  40. {
  41. doesExist = true;
  42. break;
  43.  
  44. }
  45.  
  46. books--;
  47. count++;
  48. }
  49.  
  50. if (doesExist == false)
  51. {
  52. cout << "The book you search is not here!" << endl;
  53. cout << "You checked " << count << " books.";
  54.  
  55. }
  56. else
  57. {
  58. cout << "You checked " << count << " books and found it." << endl;
  59.  
  60.  
  61. }
  62.  
  63. return 0;
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement