Quanta enfasi scara , l'unico rischio nel mio codice, così come nei tuoi è una vulnerabilità del tipo division by zero, ma facilmente ovviabile. Originariamente inviata da Scara95 Piuttosto codice: int sum(const struct tipo1 *p, n, acc) { if(n == 0) return acc; else return sum(p, n-1, acc + p[n-1]); } double media(const struct tipo1 *p, n) { return sum(p, n, 0) / ((double)n); } p è un puntatore a strutture tipo1, forse volevi scrivere acc + p[n-1].voto
int sum(const struct tipo1 *p, n, acc) { if(n == 0) return acc; else return sum(p, n-1, acc + p[n-1]); } double media(const struct tipo1 *p, n) { return sum(p, n, 0) / ((double)n); }
01010011 01100001 01101101 01110101 01100101 01101100 01100101 01011111 00110111 00110000 All errors are undocumented features waiting to be discovered.
Regole del Forum