Advertisement
STANAANDREY

ex7

Jan 18th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {//problema 7
  7.     cout<<"1.Triunghi"<<endl;
  8.     cout<<"2.Dreptunghi"<<endl;
  9.     cout<<"3.Cerc"<<endl;
  10.     cout<<"4.Terminare"<<endl;
  11.     unsigned short opt;
  12.     float A,P;
  13.     cout<<"Optiunea d-voastra:";
  14.     cin>>opt;
  15.     switch (opt)
  16.     {
  17.      case 1: float a,b,c,p;
  18.      cout<<"a=";cin>>a;
  19.      cout<<"b=";cin>>b;
  20.      cout<<"c=";cin>>c;
  21.      P=a+b+c;
  22.      p=P/2;
  23.      A=sqrt(p*(p-a)*(p-b)*(p-c)); break;
  24.      case 2: float l,L;
  25.      cout<<"l=";cin>>l;
  26.      cout<<"L=";cin>>L;
  27.      P=2*(l+L);
  28.      A=l*L; break;
  29.      case 3: float r;
  30.      P=2*r*M_PI;
  31.      A=r*r*M_PI; break;
  32.      case 4: return 0;
  33.      default : cout<<"OPTIUNE INEXISTENTA!!!";
  34.     }
  35.      cout<<"P="<<P<<endl;
  36.      cout<<"A="<<A<<endl;
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement