- //冒泡排序
- void sortBubble(int t[],int size,int style)
- {
- //style:1升序
- int temp = 0;
- int x;
- for (int m=0;m<size;m++)
- {
- for (int n=m+1;n<size;n++)
- {
- temp = t[m];
- if (1 == style)
- {
- if (temp>t[n])
- {
- x = temp;
- t[m] = t[n];
- t[n] = x;
- }
- }
- else
- {
- if (temp<t[n])
- {
- x = temp;
- t[m] = t[n];
- t[n] = x;
- }
- }
- }
- }
- }
转载于:https://blog.51cto.com/shpshao/453684