#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> void paixu(int* arr, int sz) { int i; for(i=0;i<sz-1;i++) { int flag = 1,j; for (j = 0; j < sz - 1-i; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; flag = 0; } } if (flag == 1) break; } } int main() { int i; int arr[] = {8,9,10,7,4,5,6,3,2,1 }; int sum = sizeof(arr) / sizeof(arr[0]); paixu(arr, sum); for (i = 0; i < sum; i++) printf("%d ", arr[i]); }