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