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[30], prenume[30];
- unsigned ven, nrmem;
- } ELEV;
- int main()
- {
- ELEV e[100], efb[100];
- int m, L;
- cout << "m=";
- cin >> m;
- cout << "L=";
- cin >> L;
- cout << "date elevi:" << endl;
- for (int i = 0; i < m; i++)
- cin >> e[i].nume >> e[i].prenume >> e[i].nrmem >> e[i].ven;
- int cnt = 0;
- for (int i = 0; i < m; i++)
- {
- int verpermem = e[i].ven / e[i].nrmem;
- if (verpermem >= L)
- efb[cnt++] = e[i];
- }
- int sortat = 0;
- while (!sortat)
- {
- sortat = 1;
- for (int i = 0; i < cnt - 1; i++)
- if (strcmp(efb[i].nume, efb[i + 1].nume) > 0)
- {
- ELEV eaux = efb[i];
- efb[i] = efb[i + 1];
- efb[i + 1] = eaux;
- }
- else if (!strcmp(efb[i].nume, efb[i + 1].nume) && strcmp(efb[i].prenume, efb[i + 1].prenume) > 0)
- {
- ELEV eaux = efb[i];
- efb[i] = efb[i + 1];
- efb[i + 1] = eaux;
- }
- }
- cout << "lista elevi fara bursa:" << endl;
- for (int i = 0; i < cnt; i++)
- cout << efb[i].nume << ' ' << efb[i].prenume << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement