也可以用c#实现选择法排序 using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { public void Sort(int[] arr) { for (int i = 0; i < arr.Length; i++) { int min=i; for (int j = i + 1; j < arr.Length; j++) { if (arr[j] < arr[min]) min = j; } int t=arr; arr=arr[min]; arr[min] = t; } } static void Main(string[] args) { int [] array = new int[] { 1,2,3,4,7,9,5,1,258,5,41,6,455,2,}; Program pro= new Program(); pro.Sort(array); foreach (int m in array) Console.WriteLine(m); Console.Read(); } } }
///冒泡排序 bubble sorting int t; int[] a ={150,56,20,94,97,123}; for(int j =a.Length-1;j>0;j--) { for(int i =0;i