using System; using System.Collections.Generic; using System.Text; namespace 数组排列 ...{ class Program ...{ staticvoid Main(string[] args) ...{ int a=3; int[] str =newint[5] ...{ 4, 2, 9, 8, 7 };//声明初始化要排序的数组 for (int i =0; i <=4; i++)//比较的次数循环 ...{ int j =0; bool comeup =false;//判断交换发生的bool变量 while (j <= a)//数组比较循环 ...{ int b =0;//这是一个中转变量 if (str[j] >str[j+1])//如果前一个数组成员的值大于后一个数组成员则进行值交换 ...{ b = str[j+1]; str[j+1] = str[j]; str[j] = b; comeup =true; } j++; } if (comeup==false)//如果值未进行过值交换,那么退出循环 ...{ for (int l =0; l <=4; l++) ...{ Console.Write(str[l]); } break; } a--;//a的值减小1 } } } }