typedef struct{ int numero; // purchase number (key): {1000, …, 2000 } int NIF; // taxpayer number: { 123450, ..., 123460 } int dia; // day of purchase int mes; // month of purchase int ano; // year of purchase: { 2020, ..., 2024 } float valor; // amount to pay for the purchase (in euros): [1.0, 500.0] }INFOLista; /* ------------------------------------------------------- */ /* --------------- library function headers -------------- */ /* ------------------------------------------------------- */ // shows a given element of type INFOLista void mostrarElementoLista(INFOLista); // to create and to return an element of type INFOLista, // using randomly generated values INFOLista criarElementoLista(); // given two elements of type INFOLista, // to compare them according to the "key" field (number); // to return: -1 (first < second), 0 (equal), 1 (first > second) int compararElementosLista(INFOLista, INFOLista); /* ------------------------------------------------------- */ /* ------------- implementation of functions ------------- */ /* ------------------------------------------------------- */ void mostrarElementoLista(INFOLista X) { printf("%d - ", X.numero); printf("%6d - ", X.NIF); printf("%2d/%2d/%4d - ", X.dia, X.mes, X.ano); printf("%6.2f\n", X.valor); } INFOLista criarElementoLista() { INFOLista X; float soma; X.numero = gerarNumeroInteiro(1000, 2000); X.NIF = gerarNumeroInteiro(123450, 123460); X.dia = gerarNumeroInteiro(1, 28); X.mes = gerarNumeroInteiro(1, 12); X.ano = gerarNumeroInteiro(2020, 2024); X.valor = gerarNumeroReal(1.00, 500.00); return X; } int compararElementosLista(INFOLista X, INFOLista Y) { if (X.numero > Y.numero) return 1; if (X.numero < Y.numero) return -1; return 0; }