artemgf

Ниточка

Mar 30th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <set>
  6. #include <map>
  7. #include <algorithm>
  8. #include <string>
  9. #include <math.h>
  10. #include <vector>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14.  
  15. struct cord
  16. {
  17.     double x, y;
  18. };
  19.  
  20. int main(void)
  21. {
  22.     cord data[101];
  23.     double line = 0;
  24.     double r, n;
  25.  
  26.     cin >> n >> r;
  27.  
  28.     cout.setf(ios::fixed);
  29.     cout.precision(2);
  30.     line = r*M_PI*2;
  31.  
  32.     for (int i = 1; i <= n; i++)
  33.         cin >> data[i].x >> data[i].y;
  34.  
  35.     for (int i = 1; i <= n; i++)
  36.         if (i != n)
  37.             line = line + sqrt(abs(pow(data[i].x - data[i + 1].x, 2) + pow(data[i].y - data[i + 1].y, 2)));
  38.         else
  39.             line = line + sqrt(abs(pow(data[i].x - data[1].x, 2) + pow(data[i].y - data[1].y, 2)));
  40.  
  41.     cout << line;
  42.    
  43.     _getch();
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment