using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int[] arr = new int[] { 63, 4, 24, 1, 3, 15 };
int min;
for (int i = 0; i < arr.Length; i++)
{
min = i;
for (int j = i + 1; j < arr.Length; j++)
{
if (arr[j] < arr[min])
min = j;
}
int t = arr[min];
arr[min] = arr[i];
arr[i] = t;
}
Console.WriteLine("排序后的结果为: ");
foreach (int n in arr)
Console.Write("{0}", n + "");
Console.WriteLine();
}
}
}
选择排序C#
最新推荐文章于 2024-04-01 17:57:41 发布