#include <stdio.h>

enum { INITNUM = 20 };

int readscores(double **dpp) {
    size_t curnum, n;
    double *p, *q, x;

    if ((p = (double*)malloc(INITNUM*sizeof(double))) == NULL) {
        printf("No memory. Stop\n");
        *dpp = NULL;
        return 0;
    }

    for(curnum = INITNUM, n = 0; scanf("%lf", &x) == 1; ++n) {
        if (n == curnum) {
            q = (double*)realloc(p, 2*curnum*sizeof(double));
            if (q == NULL) {
                printf("No enough memory. Process %d scores.\n", n);
                break;
            }
            p = q; curnum *= 2;
        }
        p[n] = x;
    }
    *dpp = p;

    return n;
}

