您的位置:首页 > 编程语言 > C#

冒泡排序的C#实现

2008-02-19 21:20 239 查看
1class Program

2 {

3 public static void Main()

4 {

5 int[] sortArray ={ 1, 3, 6, 10, 76, 4, 54, 33, 11, 24, 44 };

6 FuncSort(sortArray);

7 Console.ReadLine();

8 }

9

10 public static void FuncSort(int[] sortArray)

11 {

12

13 int tempInt;

14 for (int i = 0; i < sortArray.Length; i++)

15 {

16 for (int j = i + 1; j < sortArray.Length; j++)

17 {

18 if (sortArray[i] > sortArray[j])

19 {

20 tempInt = sortArray[i];

21 sortArray[i] = sortArray[j];

22 sortArray[j] = tempInt;

23 }

24 }

25 }

26

27 foreach (int i in sortArray)

28 {

29 Console.Write("{0},", i);

30 }

31

32 }

33 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: