18.08.2013 Views

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

#include <br />

#include <br />

#define MAX_STUD (5)<br />

struct studente {<br />

char nome[80];<br />

int voto;<br />

};<br />

struct studente stud[MAX_STUD];<br />

int main()<br />

{<br />

char s[100];<br />

int cont = 0;<br />

int err = 0;<br />

int somma = 0;<br />

}<br />

while ((fgets(s, sizeof(s), stdin)) && (cont < MAX_STUD)) {<br />

sscanf(s, "%80s %d", stud[cont].nome, &stud[cont].voto);<br />

if (stud[cont].voto >= 18 && stud[cont].voto 0)<br />

somma /= cont;<br />

printf("studenti %d, media %d errori %d\n", cont, somma, err);<br />

return 0;<br />

Figura 12.1: Il programma voti.c.<br />

120

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!