mitakvd

02. Distance

Oct 28th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. class Distance
  6. {
  7.     int x1, y1, x2, y2;
  8. public:
  9.     void get()
  10.     {
  11.         cin >> x1 >> y1 >> x2 >> y2;
  12.     }
  13.     void calc()
  14.     {
  15.         int coordination;
  16.         double distance;
  17.         coordination = (pow(x2 - x1, 2) + pow(y2 - y1, 2));
  18.         distance = sqrt(coordination);
  19.         cout.setf(ios::fixed);
  20.         cout.precision(3);
  21.         cout << distance << endl;
  22.     }
  23. };
  24.  
  25.  
  26. int main()
  27. {
  28.     Distance output;
  29.     output.get();
  30.     output.calc();
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment