#include #include #include #define DATELEN 16 #define NAMELEN 16 enum month_t { JAN=1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }; int max_day[] = {31,28,31,30,31,30,31,31,30,31,30,31}; struct date { enum month_t month; int day; }; /* print date d to stdout */ void print_date( const struct date * d) { printf("%d/%d", d->month,d->day); } /* returns 1 if month of p2 later than month of p2 * 0 otherwise */ int greaterThan_Month( const void * p1, const void * p2 ) { const struct date * d1 = (const struct date *) p1; const struct date * d2 = (const struct date *) p2; if ( d1->month < d2->month ) return -1; else if ( d1->month == d2->month ) return 0; else /* d1->month > d2->month */ return 1; } /* returns 1 if date of p2 later than month of p2 * 0 otherwise */ int greaterThan( const void * p1, const void * p2 ) { /* INCOMPLETE */ return 0; } int main() { int i; struct date date_arr[DATELEN]; srand(time(NULL)); /* randomly generate dates */ for (i=0;i