powerofsoul

chestie

Mar 4th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. struct elev
  4. {
  5.     char nume[20];
  6.     int nrc;
  7.     float note[3];
  8.     float calculeaza_medie()
  9.     {
  10.         int s = 0;
  11.         for (int i = 0; i < 3; i++)
  12.             s = s + note[i];
  13.         return s/3;
  14.  
  15.     }
  16. } v[20];
  17.  
  18. int main()
  19. {
  20.     int i, j, n, l, k;
  21.     float medie[100];
  22.     cout << "Numarul elevilor: ";
  23.     cin >> n;
  24.  
  25.     for (i = 0; i<n; i++)
  26.     {
  27.         cout << "Nrc: ";
  28.         cin >> v[i].nrc;
  29.         cout << "Elevul " << i + 1 << ":";
  30.         cin >> v[i].nume;
  31.         cout << "Note: ";
  32.         for (l = 0; l<3; l++)
  33.         {
  34.             cin >> v[i].note[l];
  35.         }
  36.         cout << v[i].calculeaza_medie() << endl;
  37.  
  38.     }
  39. }
Add Comment
Please, Sign In to add comment