//冒泡排序 void main(){ int a[] = { 3, 2, 1, 5, 4 }; int max = sizeof(a) / sizeof(a[0]); for (int i = 0; i<max - 1; i++) { for (int j = i; j<max; j++) { if (a[i]>a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for (int i = 0; i < max; i++) { printf("%d",a[i]); } getchar(); }
感觉这东西两天不用就会忘掉了..........
时间: 2024-10-11 05:16:48