using System.Threading; namespace 由小到大 { class Program { static void Main(string[] args) { Console.Write("输入个数:"); int[] a = new int[int.Parse(Console.ReadLine())]; int i = a.Length; for (int b = 0; b < i; b++) { Thread.Sleep(500); Random r = new Random(); a[b] = r.Next(1, 99); Console.Write(" " + a[b]); } Console.Write(" 由小到大"); int x, y; for ( x = 0; x < i; x++) { for ( y = x; y < i ; y++) { if (a[x] > a[y]) { int k = a[y]; a[y] = a[x]; a[x] = k; } } Console.Write(" " + a[x]); } //foreach(int k in a ) //Console.Write(" " + k]); Console.ReadLine(); } } }