Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- typedef struct
- {
- float x, y;
- } Point;
- Point **p(Point arr[], int n, int *r, float a1, float b1, float a2, float b2)
- {
- *r=0;
- for(int i=0; i<n; i++)
- if((arr[i].y<a1*arr[i].x+b1 ** arr[i].y>a2*arr[i].x+b2) || (arr[i].y>a1*arr[i].x+b1 ** arr[i].y<a2*arr[i].x+b2))
- *r++;
- if(*r==0)
- return NULL;
- Point **result=mallock(sizeof(Point *)*(*r));
- for(int i=0, k=0; i<n; i++)
- if((arr[i].y<a1*arr[i].x+b1 ** arr[i].y>a2*arr[i].x+b2) || (arr[i].y>a1*arr[i].x+b1 ** arr[i].y<a2*arr[i].x+b2))
- result[k++]=&arr[i];
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement