Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int contains_in(float x, float y, float cx, float cy, int radius)
  5. {
  6. if(x*x - 2*cx*x + cx*cx + y*y - 2*cy*y + cy*cy <= radius*radius )
  7. return 1;
  8. else
  9. return 0;
  10. }
  11.  
  12. int contains_count(float points[], float cx, float cy, int radius)
  13. {
  14. for(int i = 0; i < 10; i += 2)
  15. {
  16. if(contains_in(points[i], points[i+1], cx,cy, radius) == 0)
  17. return 0;
  18. }
  19. return 1;
  20. }
  21.  
  22.  
  23. int main()
  24. {
  25. float x = 1;
  26. float y = 2;
  27. float cx = 0;
  28. float cy = 9;
  29. int R = 5;
  30. int cifra = contains_in(x, y, cx, cy, R);
  31. printf("%d\n", cifra);
  32. float masil[10] = {1,2,2,2,1,3};
  33. cifra = contains_count(masil, cx, cy, R);
  34. printf("%d", cifra);
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement