As for what went wrong with your attempt:
* You've written score1 twice in your scanf.
* You need to take the absolute value of the difference.
* The return value is meaningless (as is the if around the recursive call).
Once these problems are fixed, it looks almost identical to mine except that you are using a pointer instead of the return value for the result.
Code:
#include <stdio.h>
#include <stdlib.h>
void recurse(int* diff) {
int score1, score2;
if (scanf("%d %d", &score1, &score2) != 2)
return;
recurse(diff);
int currDiff = abs(score1 - score2);
*diff = currDiff > *diff ? currDiff : *diff;
printf("%d %d %d\n", score1, score2, currDiff);
}
int main() {
int diff = 0;
recurse(&diff);
printf("%d\n", diff);
}
As for the use of realloc, it isn't that bad.
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int a, b;
} Score;
int main() {
int size = 0, allocated = 10;
Score *scores = malloc(allocated * sizeof *scores);
for (int a, b; scanf("%d%d", &a, &b) == 2; ) {
if (size >= allocated) {
allocated = allocated * 3 / 2;
scores = realloc(scores, allocated * sizeof *scores);
}
scores[size++] = (Score){a, b};
}
int biggest = 0;
for (int i = size; i-- > 0; ) {
int dif = abs(scores[i].a - scores[i].b);
if (dif > biggest)
biggest = dif;
printf("%d %d %d\n", scores[i].a, scores[i].b, dif);
}
printf("%d\n", biggest);
free(scores);
return 0;
}