From 97708b347f181ec632ba0b2b0f2f30e97fe5a0e0 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 11 Jan 2017 18:38:15 +0100 Subject: esericizi novembre e 11/1/17 --- val_studenti.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 val_studenti.cc (limited to 'val_studenti.cc') diff --git a/val_studenti.cc b/val_studenti.cc new file mode 100644 index 0000000..6e4d02f --- /dev/null +++ b/val_studenti.cc @@ -0,0 +1,47 @@ +//visualizzare la media e i voti positivi di n materie di n studenti +//usato il compilatore GNU GCC + +#include +#include + +using namespace std; + +int main() +{ + int studenti, somma = 0, materie, positivi, i = 0, j; + float media, voto; + string nome; + + cout << "Quanti studenti? "; + cin >> studenti; + + + cout << "Quante materie? "; + cin >> materie; + cout << "\n"; + + do { + positivi = 0; + media = 0; + j = 0; + somma = 0; + cout << "Nome: "; + cin >> nome; + + do { + cout << "Inserisci voto: "; + cin >> voto; + + if (voto >= 6) positivi++; + + somma += voto; + j++; + } while(j < materie); + + media = (float) somma / (float) materie; + cout << "La media dei voti dell'alunno " << nome << " e': " << media << ". Considerando " << positivi << " voti positivi.\n" << endl; + i++; + } while(i < studenti); + + return 0; +} -- cgit v1.2.3-18-g5258