#include <stdio.h>
#include <stdlib.h>
static int count;
typedef struct {
int x;
int y;
}Box;
Box* push(Box* memptr, int x, int y){
int i;
for (i = 0; i < count; i++){
if ((memptr[i].x == x) && (memptr[i].y == y)) {
return memptr;
}
}
count++;
if (count == 1) {
memptr = (Box*)malloc(sizeof(Box));
}else{
memptr = (Box*)realloc(memptr, sizeof(Box) * count);
}
memptr[count - 1].x = x;
memptr[count - 1].y = y;
return memptr;
}
Box* find_wet_boxes(Box* memptr, int x, int y){
if ((x * y) < 0) {
return memptr;
} else {
memptr = push(memptr, x, y);
find_wet_boxes(memptr, x, y - 1);
return find_wet_boxes(memptr, x + 1, y - 1);
}
}
int main(){
Box* memptr = NULL;
// int i;
memptr = find_wet_boxes(memptr, 1, 3);
// memptr = find_wet_boxes(memptr, 3, 2);
// memptr = find_wet_boxes(memptr, 0, 6);
// memptr = find_wet_boxes(memptr, 1, 1);
printf("count = %d\n", count);
return 0;
}