Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. void pitagoras(/*double A, double B, double C,*/ double a, double b, double c); /*Skaiciavimu funkcijos paskelbimas*/
  7. void vaizdas(); /*Trimapio vazido funkcijos paskelbimas*/
  8.  
  9. int main()
  10. {
  11.     setlocale(LC_ALL, "Lithuanian");
  12.  
  13.     vaizdas(); /*Trimapio vazido funkcijos iskvietimas*/
  14.  
  15.     double /*A, B, C,*/ a, b, c;
  16.    
  17.     cout << "Iveskite duomenis (Jeigu duomenu nezinote rasykite 0)" << endl; /*Dialogo pradžia*/
  18.     cout << "Privalote ivesti bent 2 skaicius:" << endl;
  19.    
  20.     cout << "Krastine a: ";
  21.     cin >> a;
  22.     cout << "Krastine b: ";
  23.     cin >> b;
  24.     cout << "Krastine c: ";
  25.     cin >> c;
  26.  
  27.     /*cout << "Kampas A: ";
  28.     cin >> A;
  29.     cout << "Kampas B: ";
  30.     cin >> B;
  31.     cout << "Kampas C: ";
  32.     cin >> C; */                                                            /*Dialogo pabaiga*/
  33.    
  34.  
  35.     pitagoras(/*A,B,C,*/a,b,c); /*Skaiciavimu funkcijos iskvietimas*/
  36. }
  37.  
  38. void pitagoras(/*double A, double B, double C, */double a, double b, double c) /*Skaiciavimu funckcijos skaiciavimas*/
  39. {
  40.     if (a != 0 && b != 0)
  41.     {
  42.         c = sqrt((a * a) + (b * b));
  43.         cout << "Izambines c ilgis yra: " << c << endl;
  44.     }
  45.  
  46.     else if (a != 0 && c != 0)
  47.     {
  48.         b = sqrt ((a * a) - (c * c));
  49.        
  50.             if (b < 0)
  51.             {
  52.                 b = sqrt ((a * a) - (c * c));
  53.                 cout << "Statinio b ilgis yra: " << b << endl;
  54.             }
  55.             else
  56.             {
  57.                 b = sqrt ((c * c) - (a * a));
  58.                 cout << "Statinio b ilgis yra: " << b << endl;
  59.             }
  60.     }
  61.    
  62.     else
  63.     {
  64.         a = sqrt ((b * b) - (c * c));
  65.  
  66.             if (a < 0)
  67.             {
  68.                 a = (c * c) - (b * b);
  69.                 cout << "Statinio a ilgis yra: " << a << endl;
  70.             }
  71.             else
  72.             {
  73.                 a = sqrt ((b * b) - (c * c));
  74.                 cout << "Statinio a ilgis yra: " << a << endl;
  75.             }
  76.     }
  77.    
  78.  
  79.  
  80. }
  81.  
  82. void vaizdas() /*Trimapio vazido funkcijos vaizdas*/
  83. {
  84.     cout << "  A" << endl;
  85.     cout << "  *" << endl;
  86.     cout << "  * *" << endl;
  87.     cout << "  * * *" << endl;
  88.     cout << "a * * * * c" << endl;
  89.     cout << "  * * * * *" << endl;
  90.     cout << "  * * * * * *" << endl;
  91.     cout << "C * * * * * * * B" << endl;
  92.     cout << "        b        " << endl;
  93.     cout << endl;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement