Professional Documents
Culture Documents
Barilotto PDF
Barilotto PDF
h>
#include <stdlib.h>
typedef struct
{
int giorno;
char mese[4];
int estratti[5];
}estrazione;
int main()
{
int i = 0, dim = 1, scelta;
FILE *input, *output;
estrazione *est;
est = (estrazione*) malloc(sizeof(estrazione));
input = fopen("./BariLotto.txt", "r");
while(!feof(input))
{
fscanf(input, "%d %s %d %d %d %d %d", &est[i].giorno, est[i].mese, &est[i].estratti[0],
&est[i].estratti[1], &est[i].estratti[2], &est[i].estratti[3], &est[i].estratti[4]);
dim++;
est = (estrazione*) realloc(est, dim * sizeof(estrazione));
i++;
}
--dim;
est = (estrazione*) realloc(est, --dim * sizeof(estrazione));
while (1)
{
printf("1)Stampa\n");
printf("2)Estrazioni di un numero\n");
printf("3)Ricerca ambo\n");
printf("4)Frequenze\n");
scanf("%d", &scelta);
switch (scelta)
{
case 1:
stampa(est, dim);
break;
case 2:
Nnumero(est, dim);
break;
}
}
}