MartinPaunov

Rectangle2DArea

Feb 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4.  
  5.  
  6. using namespace std;
  7. int main()
  8. {
  9.     double x1, y1, x2, y2;
  10.  
  11.     cin >> x1 >> y1 >> x2 >> y2;
  12.  
  13.     double area = abs(x2 - x1) * abs(y1 - y2);
  14.  
  15.     double perimeter = 2 * (abs(x2 - x1) + abs(y1 - y2));
  16.  
  17.     cout << fixed << setprecision(4) << area << endl;
  18.  
  19.     cout << perimeter << endl;
  20.  
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment