summaryrefslogtreecommitdiff
path: root/val_studenti.cc
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-01-11 18:38:15 +0100
committerSanto Cariotti <sancn@live.com>2017-01-11 18:38:15 +0100
commit97708b347f181ec632ba0b2b0f2f30e97fe5a0e0 (patch)
tree6b786bf228a5e8b3547a64e79fe72900dbf7158c /val_studenti.cc
parent6b2b12eb72a47133770531c05bb3d1b569d91591 (diff)
esericizi novembre e 11/1/17
Diffstat (limited to 'val_studenti.cc')
-rw-r--r--val_studenti.cc47
1 files changed, 47 insertions, 0 deletions
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 <iostream>
+#include <string>
+
+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;
+}