Advertisement
STANAANDREY

EX6

Jan 18th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {//problema 6
  6.  unsigned short n1,n2,n3,opt;
  7.    cout<<"1.Media notelor;"<<endl;
  8.    cout<<"2.Nota minima;"<<endl;
  9.    cout<<"3.Nota maxima;"<<endl;
  10.    cout<<"Optiunea dvs. e <1/2/3>: ";cin>>opt;
  11.    cout<<"n1=";cin>>n1;
  12.    cout<<"n2=";cin>>n2;
  13.    cout<<"n3=";cin>>n3;
  14.    switch (opt)
  15.    {
  16.        case 1: cout<<"Media aproximata: "<<(n1+n2+n3)/3<<endl;
  17.                cout<<"Media exacta: "<<(float)(n1+n2+n3)/3;
  18.                break;
  19.        case 2: unsigned short mini;
  20.          mini=(n1<n2)?n1:n2;
  21.          mini=(mini<n3)?mini:n3;
  22.            cout<<"Nota minima:"<<mini;break;
  23.        case 3: unsigned short maxi;
  24.          maxi=(n1<n2)?n2:n1;
  25.          maxi=(maxi<n3)?n3:maxi;
  26.          cout<<"Nota maxima:"<<maxi;break;
  27.          default : cout<<"OPTIUNE INEXISTENTA!";
  28.    }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement