From f2d61d00491215c1a6997ee6a5ced11d47cba316 Mon Sep 17 00:00:00 2001 From: Andrea Trentini Date: Thu, 24 Oct 2019 16:56:13 +0200 Subject: [PATCH] lab 24 ottobre --- atrent/2019-10-24/esercizio.go | 18 ++++++++++++++++++ atrent/2019-10-24/input | 1 + atrent/2019-10-24/voto_valido.go | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 atrent/2019-10-24/esercizio.go create mode 100644 atrent/2019-10-24/input create mode 100644 atrent/2019-10-24/voto_valido.go diff --git a/atrent/2019-10-24/esercizio.go b/atrent/2019-10-24/esercizio.go new file mode 100644 index 0000000..85bee20 --- /dev/null +++ b/atrent/2019-10-24/esercizio.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +/* TRASFORMARLO in un programma che entra in ciclo e legge numeri da stdin fino all'inserimento di un NON-numero e stampa pari/dispari per ogni numero inserito + */ +func main() { + var num1 int + fmt.Print("inserisci un numero: ") + fmt.Scanf("%d\n", &num1) + //fmt.Scan(&num1) + if (num1 % 2) == 0 { + fmt.Println("pari") + } else { + fmt.Println("dispari") + } + //fmt.Printf("%c\n", num1) //Output +} diff --git a/atrent/2019-10-24/input b/atrent/2019-10-24/input new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/atrent/2019-10-24/input @@ -0,0 +1 @@ +7 diff --git a/atrent/2019-10-24/voto_valido.go b/atrent/2019-10-24/voto_valido.go new file mode 100644 index 0000000..624435f --- /dev/null +++ b/atrent/2019-10-24/voto_valido.go @@ -0,0 +1,18 @@ +// soluzione caricata su upload e discussa in aula +package main + +import "fmt" + +func main() { + var voto, i int + for i <= 0 { + fmt.Print("inserisci voto") + fmt.Scan(&voto) + if voto < 0 || voto > 30 { + fmt.Println("reinserisci numero") + } else { + i = 1 + } + } + +} -- GitLab