标签:ons 选择结构 length 语言 sum write 冒泡排序 输出 arp
int[] num = new int[] {23,76,54,87,51,12 }; //冒泡排序 for (int i = 0; i < num.Length - 1; i++) { for (int j = 0; j < num.Length - 1 - i; j++) { if (num[j] > num[j + 1]) { int sum = num[j]; num[j] = num[j + 1]; num[j + 1] = sum; } } } //选择排序 for (int i = 0; i < num.Length - 1; i++) { for (int j = i + 1; j < num.Length; j++) { if (num[i] > num[j]) { int num1 = num[i]; num[i] = num[j]; num[j] = num1; } } }
//输出语句 for (int i = 0; i < num.Length;i++ ) { Console.WriteLine(num[i]); }
标签:ons 选择结构 length 语言 sum write 冒泡排序 输出 arp
原文地址:https://www.cnblogs.com/47Nine/p/9948114.html