Advertisement
Josif_tepe

Untitled

Apr 21st, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Student {
  6.     int br_indeks;
  7.     int oceni[40];
  8.     int br_oceni;
  9.    
  10.     double prosek() {
  11.         double p = 0.0;
  12.         for(int i = 0; i < br_oceni; i++) {
  13.             p += oceni[i];
  14.         }
  15.         p /= (double) br_oceni;
  16.         return p;
  17.     }
  18.     bool dobil_nagrada() {
  19.         if(prosek() >= 9.0) {
  20.             return true;
  21.         }
  22.         else {
  23.             return false;
  24.         }
  25.     }
  26.     void pecati() {
  27.         cout << br_indeks << " " << br_oceni << endl;
  28.         cout << prosek() << endl;
  29.     }
  30. };
  31. struct LaboratoriskaGrupa {
  32.     Student students[20];
  33.     int br_studenti;
  34.     int br_vezbi[20];
  35.    
  36.     int kolku_vezbi(int ind) {
  37.         for(int i = 0; i < br_studenti; i++) {
  38.             if(students[i].br_indeks == ind) {
  39.                 return br_vezbi[i];
  40.             }
  41.         }
  42.         return -1;
  43.     }
  44.     int kolku_potpisi() {
  45.         int brojac = 0;
  46.         for(int i = 0; i < br_studenti; i++) {
  47.             if(br_vezbi[i] >= 8) {
  48.                 brojac++;
  49.             }
  50.         }
  51.         return brojac;
  52.     }
  53.    
  54.     void popolni(Student *s, int br_s, int *br_v) {
  55.         br_studenti = br_s;
  56.         for(int i = 0; i < br_s; i++) {
  57.             students[i] = s[i];
  58.             br_vezbi[i] = br_v[i];
  59.         }
  60.     }
  61.    
  62. };
  63. int main() {
  64.     int n;
  65.     cin >> n;
  66.     Student niza[n];
  67.     for(int i = 0; i < n; i++) {
  68.         cin >> niza[i].br_indeks >> niza[i].br_oceni;
  69.         for(int j = 0; j < niza[i].br_oceni; j++) {
  70.             cin >> niza[i].oceni[j];
  71.         }
  72.     }
  73.     int vezbi[n];
  74.     for(int i = 0; i < n; i++) {
  75.         cin >> vezbi[i];
  76.     }
  77.     LaboratoriskaGrupa grupa;
  78.     grupa.popolni(niza, n, vezbi);
  79.     int brojac = 0;
  80.     for(int i = 0; i < grupa.br_studenti; i++) {
  81.         if(grupa.students[i].prosek() >= 9.0) {
  82.             grupa.students[i].pecati();
  83.             brojac++;
  84.         }
  85.     }
  86.     cout << brojac << endl;
  87.     return 0;
  88. }
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement