C# programozási nyelven
int tmp = 0;
int [] tomb=new int[20];
Random rnd = new Random();
for (int i = 0; i < tomb.Length; i++)
{
tomb[i] = rnd.Next(1,200+1);
}
for (int i = tomb.Length-1; i > 0; i--)
{
for (int l = 0; l < i; l++)
{
if (tomb[l] > tomb[l + 1])
{
tmp = tomb[l];
tomb[l] = tomb[l + 1];
tomb[l + 1] = tmp;
}
}
}
for (int i = 0; i < tomb.Length; i++)
{
Console.WriteLine(tomb[i]);
}
Console.ReadKey();
int tmp = 0;
int [] tomb=new int[20];
Random rnd = new Random();
for (int i = 0; i < tomb.Length; i++)
{
tomb[i] = rnd.Next(1,200+1);
}
for (int i = tomb.Length-1; i > 0; i--)
{
for (int l = 0; l < i; l++)
{
if (tomb[l] > tomb[l + 1])
{
tmp = tomb[l];
tomb[l] = tomb[l + 1];
tomb[l + 1] = tmp;
}
}
}
for (int i = 0; i < tomb.Length; i++)
{
Console.WriteLine(tomb[i]);
}
Console.ReadKey();
Nincsenek megjegyzések:
Megjegyzés küldése