xcode冒泡排序法
// Copyright © 2016年 杨礼军. All rights reserved.
//
#import <Foundation/Foundation.h>
void bubbleSort(int arrry[]);
int main(int argc, const char * argv[]) {
int numberArray[20] = {9,2,10,399,339,33,335,467,353,246,567,896,13333,1234,5670,78,682,13,4 };
bubbleSort(numberArray);
for (int i = 0; i < 20; i++) {
printf("%d位数字是%d\n",i,numberArray[i]);
}
return 0;
}
void bubbleSort(int arrry[] ){
for (int i = 0; i < 20; i++) {
for (int j = i; j < 20; j++) {
if (arrry[i] > arrry[j] ) {
// 大数下沉策略
int temp = arrry[i];
arrry[i] = arrry[j];
arrry[j] = temp;
printf("%d我的数字\n",temp);//dfdfdfdfdfd
}
}
}
}
下载冒泡排序。