x2311

Untitled

Dec 21st, 2021
1,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct base {
  6.     string name;
  7.     int date{};
  8.     int month{};
  9. };
  10.  
  11. bool searchForTheRightMonth(base &base);
  12.  
  13. const int MONTH[]{6, 7, 8};
  14. const int SIZE = 5;
  15.  
  16. int main() {
  17.     base b[SIZE];
  18.     for (auto &i: b) {
  19.         cout << "Enter name :" << endl;
  20.         cin >> i.name;
  21.         cout << "Enter date :" << endl;
  22.         cin >> i.date;
  23.         cout << "Enter month :" << endl;
  24.         cin >> i.month;
  25.         cout << endl;
  26.  
  27.     }
  28.     for (auto &i: b) {
  29.         if (searchForTheRightMonth(i)) {
  30.             cout << i.name << "\t" << i.date << "\t" << i.month << endl;
  31.         }
  32.     }
  33. }
  34.  
  35. bool searchForTheRightMonth(base &base) {
  36.     for (int i: MONTH) {
  37.         if (base.month == i) {
  38.             return true;
  39.         }
  40.     }
  41.     return false;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment