Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- typedef struct
- {
- char nume[20], prenume[20];
- unsigned med, notateza;
- unsigned medinfo;
- } ELEV;
- int main()
- {
- ELEV e[100], cor[100];
- int n, nrcor = 0;
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> e[i].nume >> e[i].prenume >> e[i].med >> e[i].notateza;
- for (int i = 0; i < n; i++)
- {
- e[i].medinfo = (e[i].med + e[i].notateza) / 2;
- if (e[i].medinfo < 5)
- cor[nrcor++] = e[i];
- }
- int sortat = 0;
- while (!sortat)
- {
- sortat = 1;
- for (int i = 0; i < nrcor - 1; i++)
- if (strcmp(cor[i].nume, cor[i + 1].nume) > 0)
- {
- ELEV aux = cor[i];
- cor[i] = cor[i + 1];
- cor [i + 1] = aux;
- sortat = 0;
- }
- else if (!strcmp(cor[i].nume, cor[i + 1].nume) && strcmp(cor[i].prenume, cor[i + 1].prenume) > 0)
- {
- ELEV aux = cor[i];
- cor[i] = cor[i + 1];
- cor [i + 1] = aux;
- sortat = 0;
- }
- }
- for (int i = 0; i < nrcor; i++)
- cout << cor[i].nume << ' ' << cor[i].prenume << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement