Advertisement
Guest User

Übung 8-02

a guest
Mar 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double abstand(double x1, double y1, double x2, double y2);
  7.  
  8. int main()
  9. {
  10. double a1;
  11. double b1;
  12. double a2;
  13. double b2;
  14.  
  15.  
  16. cout << "Punkt 1 eingeben" << endl;
  17. cin >> a1;
  18. cin >> b1;
  19.  
  20. cout << "Punkt 2 eingeben" << endl;
  21. cin >> a2;
  22. cin >> b2;
  23. cout << "Die Strecke zwischen Punkt1 und Punkt2 ist "<< abstand(a1,b1,a2,b2) << " Einheiten lang." << endl;
  24. }
  25.  
  26. double abstand(double x1, double y1, double x2, double y2)
  27. {
  28. // Aufgabe 2.
  29. // Distanz zwischen P1 und P2
  30. double Distanz;
  31. Distanz = sqrt(pow((x2 - x1),2.)+pow((y2- y1),2.));
  32. return Distanz;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement