Advertisement
yeskendir_sultanov

Functions

Apr 21st, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. double distance(int xa, int ya, int xb, int yb) {
  6.     return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
  7. }
  8.  
  9. double getPerimeter(int xa, int ya, int xb, int yb, int xc, int yc) {
  10.     return distance(xa, ya, xb, yb) + distance(xa, ya, xc, yc) + distance(xb, yb, xc, yc);
  11. }
  12.  
  13. int main() {    
  14.     int xa, ya, xb, yb, xc, yc;
  15.     cin >> xa >> ya >> xb >> yb >> xc >> yc;
  16.     cout << getPerimeter(xa, ya, xb, yc, xc, yc) << endl;
  17.     int xp, yp, xq, yq, xr, yr;
  18.     cin >> xp >> yp >> xq >> yq >> xr >> yr;
  19.     cout << getPerimeter(xp, yp, xq, yq, xr, yr)
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement