SHARE
TWEET

ex2

a guest Mar 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. struct elev
  7. {
  8.     char nume[256],prenume[256];
  9.     int ma,t;
  10. };
  11. int main()
  12. {
  13.    int n,aux;
  14.    float m[100];
  15.    cout<<"n=";cin>>n;
  16.    cin.get();
  17.    elev v[100];
  18.    for(int i=0;i<n;i++)
  19.    {
  20.        cout<<"Nume="; cin>>v[i].nume;
  21.        cout<<"Prenume="; cin>>v[i].prenume;
  22.        cout<<"Media="; cin>>v[i].ma;
  23.        cout<<"Teza=";cin>>v[i].t;
  24.        m[i]=(float(v[i].ma*3.00)+v[i].t)/4;
  25.        m[i]=int(m[i]*100);
  26.        m[i]=float(m[i]/100);
  27.     }
  28.     for(int i=0;i<n;i++)
  29.         if(m[i]>=5.00)
  30.             cout<<v[i].nume<<" "<<v[i].prenume<<" a promovat"<<endl;
  31.         else
  32.             cout<<v[i].nume<<" "<<v[i].prenume<<" nu a promovat"<<endl;
  33.    for(int i=0;i<n-1;i++)
  34.     {
  35.         for(int j=i+1;j<n;j++)
  36.     {
  37.             if(m[i]<m[j])
  38.         {
  39.             aux=m[i];
  40.             m[i]=m[j];
  41.             m[j]=aux;
  42.         }
  43.     }
  44.     }
  45.  
  46.     cout<<"Media elevilor descrescator=";
  47.     for(int i=0;i<n;i++)
  48.         cout<<float(m[i])<<endl;
  49.     return 0;
  50. }
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