i have code with 10 random number, there i have odds and evens so i need to get separately Sum, Avarage, Maximum, Minimum for odds and separately Sum, Avarage, Maximum, Minimum for evens i must use only for cycle **NO VAR!**xD
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
int[] array = new int[10];
for (int i = 0; i < array.Length; i++)
{
array[i] = r.Next(100);
bool even;
if (array[i] % 2 == 0)
{
even = true;
}
else
{
even = false;
}
Console.Write("array[" + i + "] = " + array[i]);
if (even == true)
{
Console.WriteLine(" is even");
}
else
{
Console.WriteLine(" is odd");
}
}
Console.ReadKey();
}
}
}
Aucun commentaire:
Enregistrer un commentaire