Back

#include<stdio.h>

#define  XMAX 10
#define YMAX 20

struct point
 {
   int x;
   int y;
 };

struct rect
 {
   struct point pt1;
   struct point pt2;
 };

struct point middle;
struct rect screen;

struct point makepoint(int x, int y);

int main()
{

screen.pt1 = makepoint(0,0);
screen.pt2 = makepoint(XMAX, YMAX);

middle = makepoint ((screen.pt1.x + screen.pt2.x)/2 , (screen.pt1.y + screen.pt2.y)/2);
printf("Middle = %d, %d\n",middle.x, middle.y);

return 0;
}

struct point makepoint(int x, int y)
 {
   struct point temp;

   temp.x = x;
   temp.y = y;

   return temp;
 }

Top