插入排序


1

2

3

4

5

6



7

8



9

10



11

12



13

14

15

16



17

18

19

20

21

22

23

24

25

26

27

28

选择排序


1

2



3

4



5

6

7



8

9



10

11

12

13

14

15

16

17

18

冒泡


using System;
using System.Collections.Generic;
using System.Text;
namespace DataStructer
{
class BubbleSorter
{
public void sort(int[] list)
{
int i, j, temp;
bool done = false;
j = 1;
while ((j < list.Length) && (!done))
{
done = true;
for (i = 0; i < list.Length - j; i++)
{
if (list[i] > list[i + 1])
{
done = false;
temp = list[i];
list[i] = list[i + 1];
list[i + 1] = temp;
}
}
j++;
}
}
}
}