salve amici ho un piccolo problema
in pratica ho questo array di struct
codice:
struct indirizzo {
char strada[20];
char CAP[5];
char civico[3];
};
struct data {
short giorno;
char mese[10];
char anno[4];};
typedef struct indirizzo ind;
typedef struct data Data;
struct studente {
char nome[10];
char cognome[15];
char matricola[10];
char luognasc[25];
ind indirizzo;
Data datanascita;
short presenze[20]; };
typedef struct studente stud; stud student[30];
devo implementare una funzione per la ricerca del max,le variabili da confrontare sono le student[i].presenze[0] dove mi interesa confrontare con tutti gli studenti quindi iè l'indice che deve variare.
la funzione deve essere ricorsiva e divide et impera tipo come questa
codice:
int max_I(int a,int b)
{ if (a > b) return a;
else return b; }
int massimo_a_ricDI(int a[],int n)
{ int mediano; /* soluzione del caso base */
if(n == 1) return a[0];
else
{ /* autoattivazioni */ mediano = (n-1)/2;
return max_I(massimo_a_ricDI(a,mediano+1),massimo_a_ricDI(a+mediano+1,n-mediano-1));
}
}
non riesco ad implementarla mi sapete dare na mano? grazie