using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 选择排序
{
class Program
{
static void Main(string[] args)
{
int[] s = new int[10] { 10, 36, -55, 5, 0, 14, -416, -1236, 14, 39 };
int num;
int index;
for (int i = 0; i < s.Length - 1; i++)
{
num = s[i];
index = i;
for (int j = i + 1; j < s.Length; j++)
{
if (num > s[j])
{
num = s[j];
index = j;
}
}
int temp;
temp = s[i];
s[i] = num;
s[index] = temp;
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(s[i] + " ");
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 选择排序
{
class Program
{
static void Main(string[] args)
{
int[] s = new int[10] { 10, 36, -55, 5, 0, 14, -416, -1236, 14, 39 };
int num;
int index;
for (int i = 0; i < s.Length - 1; i++)
{
num = s[i];
index = i;
for (int j = i + 1; j < s.Length; j++)
{
if (num > s[j])
{
num = s[j];
index = j;
}
}
int temp;
temp = s[i];
s[i] = num;
s[index] = temp;
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(s[i] + " ");
}
Console.ReadKey();
}
}
}