using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 冒泡12 { class Program { static void W (int[] unsorted) { for (int i = 0; i < unsorted.Length; i++) { for (int j = 0; j < unsorted.Length-1; j++) { if (unsorted[i] > unsorted[j]) { int temp = unsorted[i]; unsorted[i] = unsorted[j]; unsorted[j] = temp; } } } } static void Main(string[] args) { Console.WriteLine("请输入第一个数字:"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第二个数字:"); int b = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第三个数字:"); int c = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第四个数字:"); int d = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第五个数字:"); int e = int.Parse(Console.ReadLine()); int[] x = {a,b, c ,d,e}; W(x); foreach (int item in x) { Console.Write(item); } Console.ReadLine(); } } }
时间: 2024-11-10 13:43:43