Commenti
This commit is contained in:
parent
faaeb388b5
commit
6deaeb4b90
14
Program.cs
14
Program.cs
@ -27,7 +27,9 @@ class Program
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
//reset variabili
|
||||
positiviPari = true;
|
||||
|
||||
do{
|
||||
Console.Write("Numeri da inserire: ");
|
||||
i = Convert.ToInt32(Console.ReadLine());
|
||||
@ -36,6 +38,7 @@ class Program
|
||||
}
|
||||
}
|
||||
while (i <= 0);
|
||||
|
||||
for (; i > 0; i--){
|
||||
Console.Write("Inserire un numero: ");
|
||||
numero = Convert.ToInt32(Console.ReadLine());
|
||||
@ -43,6 +46,7 @@ class Program
|
||||
positiviPari = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (positiviPari == true){
|
||||
Console.WriteLine("Tutti positivi e pari");
|
||||
}
|
||||
@ -51,7 +55,9 @@ class Program
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
//reset variabili
|
||||
somma = 0;
|
||||
|
||||
do{
|
||||
Console.Write("Inserire un numero: ");
|
||||
numero = Convert.ToInt32(Console.ReadLine());
|
||||
@ -59,7 +65,7 @@ class Program
|
||||
somma = somma + numero;
|
||||
}
|
||||
}
|
||||
while (!((numero < 0 && numero % 2 == 0) || (numero >= 0 && numero % 3 == 0)));
|
||||
while (!((numero < 0 && numero % 2 == 0) || (numero >= 0 && numero % 3 == 0))); // stessa condizione dell'if
|
||||
Console.WriteLine("Somma: " + somma);
|
||||
break;
|
||||
case 3:
|
||||
@ -67,12 +73,13 @@ class Program
|
||||
do{
|
||||
Console.Write("Inserire un numero: ");
|
||||
numero = Convert.ToInt32(Console.ReadLine());
|
||||
if(numero > 0 && tmp < 0){
|
||||
if(numero > 0 && tmp < 0){ //se il numero inserito è positivo e quello precedente è negativo
|
||||
positivoNegativo = true;
|
||||
}
|
||||
tmp = numero;
|
||||
}
|
||||
while (numero != 0);
|
||||
|
||||
if(positivoNegativo){
|
||||
Console.WriteLine("OK");
|
||||
}
|
||||
@ -81,7 +88,9 @@ class Program
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//reset variabili
|
||||
somma = 0;
|
||||
|
||||
do{
|
||||
Console.Write("Numeri da inserire: ");
|
||||
i = Convert.ToInt32(Console.ReadLine());
|
||||
@ -90,6 +99,7 @@ class Program
|
||||
}
|
||||
}
|
||||
while (i <= 0);
|
||||
|
||||
for (; i > 0; i--){
|
||||
Console.Write("Inserire un numero: ");
|
||||
numero = Convert.ToInt32(Console.ReadLine());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user