using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class SelSorter
{
public static void ArraySort(params int[] a)
{
int k;
for (int i = 0; i < a.Length - 1; i++)
{
k = i;
for (int j = i + 1; j < a.Length; j++)
if (a[j] < a[k])
k = j;
int tmp = a[k]; a[k] = a[i]; a[i] = tmp;
}
}
}
class Program
{
static void Main(string[] args)
{
int[] x = { 12,34,15,67,19,20};
SelSorter.ArraySort(x);
foreach (int item in x)
Console.WriteLine(item);
Console.ReadLine();
}
}
}
静态方法使用
最新推荐文章于 2023-05-05 23:41:59 发布