Advertisement
fqrmix

prozarovskiy

Dec 25th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <math.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define pi 3.14
  5.  
  6. struct Coords
  7. {
  8.     float a;
  9.     float r;
  10.     float x;
  11.     float y;
  12. };
  13.  
  14. int main()
  15. {
  16.     Coords Coordinats[100], *pointer;
  17.     pointer = &Coordinats[0];
  18.     printf("Введите количество точек\n");
  19.     unsigned int n;
  20.     scanf("%u", &n);
  21.     for (unsigned int i = 0; i < n; i++)
  22.     {
  23.         scanf("%f", &pointer->a);
  24.         scanf("%f", &pointer->r);
  25.         pointer->x = pointer->r * cos(pointer->a);
  26.         pointer->y = pointer->r * sin(pointer->a);
  27.         printf("%f %f\n", pointer->x, pointer->y);
  28.         pointer++;
  29.     }
  30.     pointer = &Coordinats[0];
  31.     float xmax = pointer->x, ymax = pointer->y, xmin = pointer->x, ymin = pointer->y;
  32.     for (size_t i = 0; i < n; i++)
  33.     {
  34.         if (xmax < pointer->x)
  35.             xmax = pointer->x;
  36.         if (xmin > pointer->x)
  37.             xmin = pointer->x;
  38.         if (ymax < pointer->y)
  39.             ymax = pointer->y;
  40.         if (ymin > pointer->y)
  41.             ymin = pointer->y;
  42.         pointer++;
  43.     }
  44.     printf("Левый верхний угол - %f,%f\n Левый нижний угол - %f,%f\n Правый верхний угол - %f,%f\n Правый нижний угол - %f,%f\n", xmin, ymax, xmin, ymin, xmax, ymax, xmax, ymin);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement