Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C# by registered user AntonisPlatis ( 4 years ago )
using System;
namespace Array_Sorting
{
internal class Program
{
public static void Main()
{
int i, j, temp, tblsize, rmin, rmax;
int[] pinakas;
Random tyxaios = new Random();
Console.Write("Please insert the size of the table: ");
tblsize = Convert.ToInt32(Console.ReadLine());
Console.Write("\n");
pinakas = new int[tblsize];
Console.Write("Please insert the MIN random value: ");
rmin = Convert.ToInt32(Console.ReadLine());
Console.Write("\n");
Console.Write("Please insert the MAX random value: ");
rmax = Convert.ToInt32(Console.ReadLine());
Console.Write("\n");
for (i = 0; i < pinakas.Length; i++)
{
pinakas[i] = tyxaios.Next(rmin, rmax);
}
Console.WriteLine("print table ------");
for (i = 0; i < pinakas.Length; i++)
{
Console.WriteLine(pinakas[i]);
}
Console.WriteLine("print alter table ------");
for (i = 0; i < pinakas.Length; i+=2)
{
Console.WriteLine(pinakas[i]);
}
for (i = 0; i < pinakas.Length - 1; i++)
{
j = tyxaios.Next(i, pinakas.Length);
temp = pinakas [i];
pinakas [i] = pinakas [j];
pinakas [j] = temp;
}
Console.WriteLine("print suffled table ------");
for (i = 0; i < pinakas.Length; i++)
{
Console.WriteLine(pinakas[i]);
}
for (j = 0; j <= pinakas.Length - 2; j++)
{
for (i = 0; i <= pinakas.Length - 2; i++)
{
if (pinakas[i] > pinakas[i + 1])
{
temp = pinakas[i + 1];
pinakas[i + 1] = pinakas[i];
pinakas[i] = temp;
}
}
}
Console.WriteLine("print sorted table ------");
for (i = 0; i < pinakas.Length; i++)
{
Console.WriteLine(pinakas[i]);
}
}
}
}
Revise this Paste