Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <conio.h>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. namespace Umlaut
  9.     {
  10.         const unsigned char AE = static_cast<unsigned char>(142);
  11.         const unsigned char ae = static_cast<unsigned char>(132);
  12.         const unsigned char OE = static_cast<unsigned char>(153);
  13.         const unsigned char oe = static_cast<unsigned char>(148);
  14.         const unsigned char UE = static_cast<unsigned char>(154);
  15.         const unsigned char ue = static_cast<unsigned char>(129);
  16.         const unsigned char ss = static_cast<unsigned char>(225);
  17.     }
  18.  
  19. void nochmal();
  20.  
  21. void close() //Bei falscher Eingabe schließen
  22. {    system ("CLS");
  23.      cout<<"\n\n\aUNG"<<Umlaut::UE<<"LTIGE EINGABE";
  24.      getch();
  25.      exit(0);   }
  26.  
  27. float Trigonometrie() //Sinus, Cosinus, Tangens
  28. {
  29.       string ent;
  30.       system("CLS");
  31.      
  32. }
  33. float Saetze() //Satz des Pythagoras etc.
  34. {
  35.       system ("CLS");
  36.       cout<<"\n\n- Satz des Pythagoras     [1]\n- H"<<Umlaut::oe<<"hensatz               [2]\n- Kathetensatz            [3]\n\n";
  37.       int ent;
  38.       cin>>ent;
  39.      
  40.       if (ent==1)
  41.       {
  42.                  system("CLS");
  43.                  cout<<"\nVorhandene Gr"<<Umlaut::oe<<Umlaut::ss<<"en eingeben  \n(Falls Gr"<<Umlaut::oe<<Umlaut::ss<<"e nicht vorhanden, 0 eingeben)";
  44.                  cout<<"\n\nHypotenuse:   ";
  45.                  float Hypotenuse;
  46.                  cin>>Hypotenuse;
  47.                  cout<<"\nKathete1:     ";
  48.                  float Kathete1;
  49.                  cin>>Kathete1;
  50.                  cout<<"\nKathete2:     ";
  51.                  float Kathete2;
  52.                  cin>>Kathete2;
  53.  
  54.                      if (Kathete1!=0 && Kathete2!=0 && Hypotenuse!=0)
  55.                      {close();}
  56.                            
  57.                      if (Hypotenuse == 0)
  58.                      {
  59.                      Hypotenuse = sqrt( Kathete1 * Kathete1 + Kathete2 * Kathete2 );
  60.                      cout<<"\n\nHypotenuse:  "<<Hypotenuse<<"";
  61.                      }
  62.      
  63.                      if (Kathete1 == 0)
  64.                      {
  65.                      Kathete1 = sqrt ( Hypotenuse * Hypotenuse - Kathete2 * Kathete2 );
  66.                      cout<<"\n\nKathete1:   "<<Kathete1<<"";
  67.                      }
  68.      
  69.                      if (Kathete2 == 0)
  70.                      {
  71.                      Kathete2 = sqrt ( Hypotenuse * Hypotenuse - Kathete1 * Kathete1 );
  72.                      cout<<"\n\nKathete2:   "<<Kathete2<<"";
  73.                      }
  74.                      
  75.                      nochmal();
  76.  
  77.       }
  78.      
  79.       if (ent==2)
  80.       {
  81.                  system("CLS");
  82.                  cout<<"\nVorhandene Gr"<<Umlaut::oe<<Umlaut::ss<<"en eingeben  \n(Falls Gr"<<Umlaut::oe<<Umlaut::ss<<"e nicht vorhanden, 0 eingeben)\n\n\n";
  83.                  cout<<"\n\nH"<<Umlaut::oe<<"he:                        ";
  84.                  float Hoehe;
  85.                  cin>>Hoehe;
  86.                  cout<<"\nHypotenusenabschnitt p:      ";
  87.                  float p;
  88.                  cin>>p;
  89.                  cout<<"\nHypotenusenabschnitt q:      ";
  90.                  float q;
  91.                  cin>>q;
  92.                  
  93.                  if (Hoehe==0)
  94.                  {
  95.                               Hoehe = sqrt( p * q );
  96.                               cout<<"\n\nH"<<Umlaut::oe<<"he:   "<<Hoehe<<"";
  97.                  
  98.                  }
  99.                  
  100.                  if (q==0)
  101.                  {
  102.                               q = ( Hoehe * Hoehe ) / p ;
  103.                               cout<<"\n\nHypotenusenabschnitt q:   "<<q<<"";
  104.                  }
  105.                  
  106.                  if (p==0)
  107.                  {
  108.                               p = ( Hoehe * Hoehe ) / q ;
  109.                               cout<<"\n\nHypotenusenabschnitt p:   "<<p<<"";
  110.                  }
  111.                  
  112.                  if (p!=0 && q!=0 && Hoehe!=0)
  113.                  {close();}
  114.                  
  115.                  nochmal();
  116.       }
  117.      
  118.       if (ent == 3)
  119.       {}
  120.      
  121.                              
  122.                  
  123. }
  124.  
  125. int main()
  126. {
  127.    
  128.     system ("CLS");
  129.    
  130.     cout<<"\n\tRechtwinklige Dreiecke";
  131.     cout<<"\n\n-  Satz des Pythagoras, H"<<Umlaut::oe<<"hensatz, Kathetensatz     [1]\n-  Sinus, Cosinus, Tangens                          [2]\n\n";
  132.     int ent;
  133.     cin>>ent;
  134.    
  135.     if (ent == 1)                       // Welche
  136.     {Saetze();}                        // Funktion                                
  137.     if (ent == 2)                     //  wird              
  138.     {Trigonometrie();}               //   aufgerufen?                  
  139.     if (ent!=1 && ent!=2)
  140.     {close();}
  141.    
  142.    
  143.    
  144.     getch();
  145.     return 0;
  146. }
  147.  
  148. void nochmal()
  149. {
  150.      cout<<"\n\n\n\n\nErneut berechnen? \n\n- Ja   [1]\n- Nein [2]\n\n";
  151.      int ent;
  152.      cin>>ent;
  153.      if (ent==1)
  154.      {main();}
  155.      if (ent==2)
  156.      {exit(0);}
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement