标签:
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(1000); Random r = new Random(); a[b] = r.Next(1, 99); Console.Write(" " + a[b]); } Console.Write("\n由小到大"); for (int x = 0; x < i; x++) { for (int y = 0; y < i - 1; y++) { if (a[y] > a[y + 1]) { int k = a[y]; a[y] = a[y + 1]; a[y + 1] = k; } } Console.Write(" " + a[x]); } Console.ReadLine();
标签:
原文地址:http://www.cnblogs.com/nwj-0613/p/4719917.html