//冒泡排序的优化
int array10[] = {9, 7, 3, 8, 4};
BOOL flag1 = YES;
for (int i = 0; i < 5 - 1 && flag1; i++) {
flag = NO;//假设本趟循环没有做交换
for (int j = 0; j < 5 - 1 - i; j++) {
if (array10[j] > array10[j + 1]) {
int temp = array10[j];
array10[j] = array10[j + 1];
array10[j + 1] = temp;
flag1 = YES;//交换就置成YES
}
}
}
原文:http://www.cnblogs.com/tian-sun/p/4270932.html