Advertisement
STANAANDREY

5 20/11/2019

Nov 20th, 2019
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. typedef struct
  7. {
  8.     int zi, l, an;
  9. } DATA;
  10.  
  11. typedef struct
  12. {
  13.     char nume[20];
  14.     DATA d;
  15. } PERS;
  16.  
  17. int main()
  18. {
  19.     int x;
  20.     PERS p[100];
  21.     int n;
  22.     cout << "x=";
  23.     cin >> x;
  24.     cout << "n=";
  25.     cin >> n;
  26.     cout << "Lista persoane:" << endl;
  27.     for (int i = 0; i < n;i++)
  28.     {
  29.         gets(p[i].nume);
  30.         cin >> p[i].d.zi >> p[i].d.l >> p[i].d.an;
  31.     }
  32.  
  33.     DATA dc;
  34.     cout << "data curenta:";
  35.     cin >> dc.zi >> dc.l >> dc.an;
  36.     for (int i = 0; i < n; i++)
  37.     {
  38.         int ani = dc.an - p[i].d.an;
  39.         if (p[i].d.l > dc.l)
  40.                 ani--;
  41.         else if (p[i].d.l == dc.l && p[i].d.zi > dc.zi)
  42.                 ani--;
  43.  
  44.         if (x == ani)
  45.             cout << p[i].nume << endl;
  46.  
  47.     }
  48.  
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement