Advertisement
STANAANDREY

1/182

Nov 5th, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ifstream fin("BAC.in");
  6. ofstream fout("BAC.out");
  7.  
  8. typedef struct
  9. {
  10.     float med;
  11.     char nume[100];
  12. } ELEV;
  13.  
  14. int main()
  15. {
  16.     ELEV e[100];
  17.     int n, prom = 0;
  18.     fin >> n;
  19.     for (int i = 0; i < n; i++)
  20.     {
  21.         fin >> e[i].med >> e[i].nume;
  22.         if (e[i].med >= 6.00)
  23.             prom++;
  24.     }
  25.  
  26.     for (int i = 0; i < n - 1; i++)
  27.         for (int j = i + 1; j < n; j++)
  28.             if (e[i].med < e[j].med)
  29.             {
  30.                 ELEV eaux;
  31.                 eaux = e[i];
  32.                 e[i] = e[j];
  33.                 e[j] = eaux;
  34.             }
  35.  
  36.     for (int i = 0; i < n; i++)
  37.         fout << e[i].med << ' ' << e[i].nume << endl;
  38.  
  39.     fout << "promovati: " << prom << endl;
  40.     fout << "respinsi: " << n - prom;
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement