daily pastebin goal
66%
SHARE
TWEET

Problema 1-a

a guest Feb 13th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct elev {
  6.     char nume[10];
  7.     char prenume[20];
  8.     int nota;
  9. } a[20], c;
  10.  
  11. int main() {
  12.     int n, i, j;
  13.     float S;
  14.  
  15.     cout << "Numarul de elevi: ";
  16.     cin >> n;
  17.     cout << "Datele despre elev: " << endl;
  18.     for (i = 1; i <= n; i++) {
  19.         cout << "Elevul " << i << ": " << endl;
  20.         cout << "Nume: ";
  21.         cin >> a[i].nume;
  22.         cout << "Prenume: ";
  23.         cin >> a[i].prenume;
  24.         cout << "Nota: ";
  25.         cin >> a[i].nota;
  26.         S += a[i].nota;
  27.     }
  28.  
  29.     for (i = 1; i < n; i++)
  30.         for (j = i + 1; j <= n; j++)
  31.             if (a[i].nota < a[j].nota) {
  32.                 c = a[i];
  33.                 a[i] = a[j];
  34.                 a[j] = c;
  35.             }
  36.  
  37.     cout << "Afisarea elevilor promovati: " << endl;
  38.     for (i = 1; i <= n && a[i].nota >= 5; i++) {
  39.         cout << a[i].nume << " " << a[i].prenume << " " << a[i].nota << " " << endl;
  40.     }
  41.  
  42.     cout << "Media notelor= " << S / n << endl;
  43.  
  44.     return 0;
  45. }
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