using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace selsort
{
class Program
{
static void Main(string[] args)
{
int[] arr;
arr = new int[10];
Random r = new Random();
for (int x = 0; x < arr.Length; x++)
{
arr[x] = r.Next(100);
}
for (int x = 0; x < arr.Length - 1; x++)
{
for (int y = x + 1; y < arr.Length; y++)
{
if (arr[x] > arr[y])
{
int temp;
temp = arr[x];
arr[x] = arr[y];
arr[y] = temp;
}
}
}
foreach (int temp in arr)
{
Console.WriteLine(temp);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace selsort
{
class Program
{
static void Main(string[] args)
{
int[] arr;
arr = new int[10];
Random r = new Random();
for (int x = 0; x < arr.Length; x++)
{
arr[x] = r.Next(100);
}
for (int x = 0; x < arr.Length - 1; x++)
{
for (int y = x + 1; y < arr.Length; y++)
{
if (arr[x] > arr[y])
{
int temp;
temp = arr[x];
arr[x] = arr[y];
arr[y] = temp;
}
}
}
foreach (int temp in arr)
{
Console.WriteLine(temp);
}
}
}
}
No comments:
Post a Comment