My code result are 10, 10, 3, 7, 9, 9, 5, 5, 10, 10, 1 and i need other result 10, 3, 7, 9, 5, 1 how to do it ? Sorry for my bad english, but i hope youll understand that what i need to do.
I need help fast pls !
int[] array1 = { 10, 3, 7, 9, 50, 5, 10, 21, 1};
int[] array2 = { 1, 8, 7, 4, 10, 5, 9};
int[] array3 = { 20, 3, 9, 5, 10, 1};
Array.Sort(array2);
Array.Reverse(array2);
Array.Sort(array3);
Array.Reverse(array3);
int i = 0;
int j = 0;
Console.WriteLine("Second array descending");
for (i = 0; i < array2.Length; i++)
{
Console.Write(array2[i].ToString() + ",");
}
Console.WriteLine();
Console.WriteLine("Third array descending");
for (j = 0; j < array3.Length; j++)
{
Console.Write(array3[j].ToString() + ",");
}
Console.WriteLine();
Console.WriteLine("First array elements");
foreach (int l in array1)
{
Console.Write(l + ",");
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Take elements from the first array");
for (i = 0; i < array1.Length; i++)
{
for (j = 0; j < array2.Length; j++)
{
for (j = 0; j < array3.Length; j++)
if (array1[i] == array2[j])
{
Console.Write(array1[i] + ",");
}
else if (array1[i] == array3[j])
{
Console.Write(array1[i] + ",");
}
}
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
}
}
}
Aucun commentaire:
Enregistrer un commentaire