Guest User

Untitled

a guest
Jul 11th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #include "iostream"
  2. #include "list"
  3. #include "string"
  4. using namespace std;
  5. class University {
  6. public:
  7.     string university;
  8.     string rektor;
  9. private:
  10.     int numberOfEmployees;
  11.     int numberOfFaculties;
  12.     int numberOfDirections;
  13.     int numberOfStudents;
  14.     int numberOfProfessors;
  15. public:
  16.     void set() {
  17.         cout << "\nUniversity's name: "; getline(cin, university);
  18.         cout << "Rektor's fullname: "; getline(cin, rektor);
  19.         cout << "Number Of Employees: "; cin >> numberOfEmployees;
  20.         cout << "Number Of Faculties: "; cin >> numberOfFaculties;
  21.         cout << "Number Of Directions: "; cin >> numberOfDirections;
  22.         cout << "Number Of Students: "; cin >> numberOfStudents;
  23.         cout << "Number Of Professors: "; cin >> numberOfProfessors;
  24.     }
  25.     void Print() {
  26.         cout << "\nUniversity's name: " << university;
  27.         cout << "\nRektor's fullname: " << rektor;
  28.         cout << "\nNumber Of Employees: " << numberOfEmployees;
  29.         cout << "\nNumber Of Faculties: " << numberOfFaculties;
  30.         cout << "\nNumber Of Directions: " << numberOfDirections;
  31.         cout << "\nNumber Of Students: " << numberOfStudents;
  32.         cout << "\nNumber Of Professors: " << numberOfProfessors;
  33.     }
  34. };
  35. void FindAndPrint(University* univer) {
  36.     string keyword; int counter = 0;
  37.     cout << "\nEnter keyword for searching: "; getline(cin, keyword);
  38.     for (int i = 0; i < 4; i++) {
  39.         if (strstr(univer[i].university.c_str(), keyword.c_str()) || strstr(univer[i].rektor.c_str(), keyword.c_str())) {
  40.             univer[i].Print(); counter++;
  41.         }
  42.     }
  43.     if (counter == 0) cout << "There is no similarities!";
  44. }
  45. int main() {
  46.     University univer[4];
  47.     cout << "Entering Universities: ";
  48.     for (int i = 0; i < 4; i++) {
  49.         univer[i].set();
  50.     }
  51.     FindAndPrint(univer);
  52.     return 0;
  53. }
Add Comment
Please, Sign In to add comment