SHARE
TWEET

Untitled

a guest Mar 26th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <iomanip>
  4. #include <fstream>
  5. using namespace std;
  6. ifstream fin("fisier.in");
  7. ofstream fout("fisier.out");
  8. struct elev
  9. {
  10.     char nume[100], prenume[100];
  11.     double media1, media2, media3, media;
  12. } v[100];
  13. void citire(struct elev v[100], int &n, int &p)
  14. {
  15.     int i;
  16.     fin >> n >> p;
  17.     for (i = 1; i <= n; i++)
  18.     {
  19.         fin >> v[i].nume >> v[i].prenume >> v[i].media1 >> v[i].media2 >> v[i].media3;
  20.     }
  21. }
  22. int mgen(struct elev v[100], int n)
  23. {
  24.     int cate = 0, i, m[100];
  25.     double s = 0;
  26.     double mcls = 0;
  27.     for (i = 1; i <= n; i++)
  28.     {
  29.         v[i].media = (v[i].media1 + v[i].media2 + v[i].media3) / 3;
  30.         mcls += v[i].media;
  31.         cout << v[i].media << ' ';
  32.     }
  33.     mcls /= n;
  34.     for (int i = 1; i <= n; i++)
  35.     {
  36.         if (v[i].media > mcls)
  37.         {
  38.             cate++;
  39.         }
  40.     }
  41.     return cate;
  42. }
  43. int main()
  44. {
  45.     int p, n;
  46.     citire(v, n, p);
  47.     if (p == 1)
  48.     {
  49.         fout << setprecision(2) << fixed << mgen(v, n);
  50.     }
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top