SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. typedef struct
  6. {
  7.     int x,y;
  8. }sPoint;
  9.  
  10. int max(int a, int b)
  11. {
  12.     return a > b ? a : b;
  13. }
  14.  
  15. int min(int a, int b)
  16. {
  17.     return a < b ? a : b;
  18. }
  19.  
  20. int vectorsModule (sPoint first, sPoint second)
  21. {
  22.     return sqrt(pow((first.x-second.x),2)+pow((first.y-second.y),2));
  23. }
  24.  
  25. int main()
  26. {
  27.     FILE *fin  = fopen("input.txt", "r");
  28.     FILE *fout = fopen("output.txt", "w");
  29.  
  30.     sPoint center, point, corner1, corner2, corner;
  31.     int rcenter,rcorner;
  32.     fscanf(fin, "%d%d%d%d%d%d", &corner1.x, &corner1.y, &corner2.x, &corner2.y, &point.x, &point.y);
  33.    
  34.     center.x =(corner1.x+corner2.x) / 2;
  35.     center.y =(corner1.y + corner2.y) / 2;
  36.  
  37.     rcenter = vectorsModule(center, point);
  38.  
  39.    
  40.     corner.x = point.x > center.x ? max(corner1.x, corner2.x) : min(corner1.x, corner2.x);
  41.     corner.y = point.y > center.y ? max(corner1.y, corner2.y) : min(corner1.y, corner2.y);
  42.  
  43.     rcorner = vectorsModule(corner, point);
  44.  
  45.     fprintf(fout, "%s", rcenter <= rcorner ? "CENTER" : "CORNER");
  46.  
  47.     fclose(fin);
  48.     fclose(fout);
  49.  
  50.     return 0;
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top