Advertisement
Guest User

klausur

a guest
Feb 6th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct rechteck
  5. {
  6.     double kante1, kante2;
  7. }r1,r2;
  8.  
  9. int main()
  10. {
  11.     double flaeche1,flaeche2,umfang1,umfang2;
  12.     cout << "Berechnung geometrischer Flaechen";
  13.     cout << endl;
  14.     cout << "=================================";
  15.     cout << endl;
  16.     cout << "Geben Sie die Daten von 2 Flaechen ein!";
  17.     cout << endl;
  18.     // Eingabe der Werte fürs Rechteck 1
  19.     cout << "Rechteck 1 Kante 1\t";
  20.     cin >> r1.kante1;
  21.     cout << "Rechteck 1 Kante 2\t";
  22.     cin >> r1.kante2;
  23.     cout << endl;
  24.    
  25.     // Eingabe der Werte fürs Rechteck 2
  26.     cout << "Rechteck 2 Kante 1\t";
  27.     cin >> r2.kante1;
  28.     cout << "Rechteck 2 Kante 2\t";
  29.     cin >> r2.kante2;
  30.     cout << endl;
  31.  
  32.  
  33.     // Ausgabe
  34.     cout << "Ausgabe";
  35.     cout << endl;
  36.     //Ausgabe der Fläche & Umfang vom Rechteck1
  37.     flaeche1 = r1.kante1 * r1.kante2;
  38.     umfang1 = (r1.kante1*2) + (r1.kante2*2);
  39.     cout << "Rechteck 1 hat die Flaeche: \t"<< flaeche1;
  40.     cout << endl;
  41.     cout << "Rechteck 1 hat den Umfang: \t"<< umfang1;
  42.     cout << endl;
  43.  
  44.     //Ausgabe der Fläche & Umfang vom Rechteck2
  45.     flaeche2 = r2.kante1 * r2.kante2;
  46.     umfang2= (r2.kante1*2) + (r2.kante2*2);
  47.     cout << "Rechteck 2 hat die Flaeche: \t"<< flaeche2;
  48.     cout << endl;
  49.     cout << "Rechteck 2 hat den Umfang: \t"<< umfang2;
  50.     cout << endl;
  51.  
  52.     //Vergleich der Flächen
  53.     if (flaeche1 > flaeche2)
  54.     {
  55.         cout << "Flaeche von Rechteck1 ist groesser"<<endl;
  56.     }
  57.     else if (flaeche1 < flaeche2)
  58.     {
  59.         cout << "Flaeche von Rechteck2 ist groesser"<<endl;
  60.     }
  61.     else if(flaeche1 == flaeche2)
  62.     {
  63.         cout << "Keine Flaeche  ist groesser"<<endl;
  64.     }
  65.  
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement