BrokeMansPC

test

Feb 26th, 2021
737
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. class Ucenik{
  7.     char ime[31];
  8.     char razred[7];
  9.     int ocene[14];
  10.     float Uspeh;
  11.     public:
  12.     void citaj(){
  13.         cout << "Ime i prezeime:";
  14.         cin.get(ime, 31, '\n');
  15.         char c;
  16.         cin.get(c);
  17.         cout << "Razred:";
  18.         cin.get(razred, 7, '\n');
  19.         cout << "Uneti ocene:\n";
  20.         for(int i = 0; i < 14; i++) {
  21.             cin>>ocene[i];
  22.         }
  23.  
  24.     };
  25.  
  26.     friend float uspehsr(Ucenik u);
  27.  
  28.     char *VratiIme(){
  29.         return ime;
  30.         }
  31.     char *VratiRazred(){
  32.         return razred;
  33.     }
  34.  
  35.     int *VratiOcene(){
  36.         return ocene;
  37.     }
  38. };
  39.  
  40.     float uspehsr(Ucenik u){
  41.         float srednja = 0.00;
  42.         for(int i=0; i < 14; i++){
  43.             if (u.ocene[i] == 1) {
  44.                 return 0;
  45.  
  46.             }
  47.             srednja+= u.ocene[i];
  48.         }
  49.             return srednja / 14;
  50.     }
  51.  
  52. int main()
  53. {
  54.     Ucenik *u;
  55.     cout << "Uneti broj ucenika\n n=";
  56.     int n, i, br;
  57.     cin >> n;
  58.     u = new Ucenik[n];
  59.     char c;
  60.     for(i=0; i<n; i++){
  61.      cin.get(c);
  62.      u[i].citaj();
  63.     }
  64.  
  65.     for(i=0; i < n; i++)
  66.     {
  67.         int *oc;
  68.         oc = u[i].VratiOcene();
  69.         cout << "Ime - " << u[i].VratiIme();
  70.         cout << "\nRazred - " << u[i].VratiRazred();
  71.         cout << "\nOcene - ";
  72.  
  73.         for (int j = 0; j < 14; j++){
  74.             cout << *(oc+i) << " ";
  75.         }
  76.  
  77.         cout << "\n";
  78.  
  79.         if(uspehsr(u[i]) == 0) {
  80.             cout << "NEDOVOLJAN";
  81.         } else {
  82.             cout << "Uspeh - " << uspehsr(u[i]) << "\n";
  83.         }
  84.  
  85.  
  86.  
  87.     }
  88.  
  89.     return 0;
  90. }
  91.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×