Advertisement
lukasd

zadanie 4 kolokwium 3

Feb 11th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. typedef struct
  4. {
  5.    float x, y;
  6. } Point;
  7.  
  8. Point **p(Point arr[], int n, int *r, float a1, float b1, float a2, float b2)
  9. {
  10.    *r=0;
  11.    for(int i=0; i<n; i++)
  12.       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))
  13.          *r++;
  14.    if(*r==0)
  15.       return NULL;
  16.  
  17.    Point **result=mallock(sizeof(Point *)*(*r));
  18.  
  19.    for(int i=0, k=0; i<n; i++)
  20.       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))
  21.          result[k++]=&arr[i];
  22.    return result;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement