Vla_DOS

Untitled

May 9th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include<iostream>
  2. #include<list>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. class People {
  8. public:
  9.     string surName;
  10.     string cityName;
  11.     string adress;
  12.  
  13. };
  14.  
  15. void Input(People* l, int n) {
  16.     string surName, cityName, adress;
  17.  
  18.  
  19.     for (int i = 0; i < n; i++) {
  20.         cout << "Введiть прiзвище: ";
  21.         cin >> surName;
  22.  
  23.         cout << "Введiть мiсто: ";
  24.         cin >> cityName;
  25.  
  26.         cout << "Введiть адресу: ";
  27.         cin >> adress;
  28.  
  29.         l[i].surName = surName;
  30.         l[i].cityName = cityName;
  31.         l[i].adress = adress;
  32.  
  33.         cout << endl;
  34.     }
  35. }
  36.  
  37. // Виводимо весь список
  38. void GetList(People* l, int n) {
  39.     for (size_t i = 0; i < n; i++)
  40.         cout << "SurName: " << l[i].surName << "\t" << "City: " << l[i].cityName << "\t" << "Adress: " << l[i].adress << endl;
  41. }
  42.  
  43. void GetListParameters(People* l, int n) {
  44.     int k = 1;
  45.     People* p;
  46.     p = l;
  47.     for (int i = 0; i < n; i++)
  48.         for (int j = i + 1; j < n; j++)
  49.             if (l[i].cityName != l[j].cityName && l[i].adress == l[j].adress) {
  50.                 cout << "SurName: " << p[j].surName << "\t" << "City: " << p[j].cityName << "\t" << "Adress: " << p[j].adress << endl;
  51.                 k++;
  52.                 if (k == 2) break;
  53.             }
  54. }
  55.  
  56.  
  57. int main() {
  58.     setlocale(0, "");
  59.     const int n = 4;
  60.     People l[n];
  61.  
  62.     Input(l, n);
  63.  
  64.     GetList(l, n);
  65.     cout << endl;
  66.     cout << "\n\n";
  67.     GetListParameters(l, n);
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment