那时候刚刚学到了冒泡排序和数组,于是突发奇想,整了一个这个排序方法...现在的我已经看不懂了
#include <stdio.h>
int main(int argc, const char * argv[]) {
int num[3][4]={33,66,22,77,11,19,55,88,12,99,44,70};
for (int i = 0;i < 3;i++){
for (int j = 0;j < 4;j++) {
for (int k = 0;k < 3;k++) {
for (int l = 0 ; l < 4; l++) {
switch (10*i+j<=10*k+l) {
case 0:
break;
case 1:
if (num[i][j]>num[k][l]) {
num[i][j] = num[i][j]^num[k][l];
num[k][l] = num[i][j]^num[k][l];
num[i][j] = num[i][j]^num[k][l];
}
break;
}
}
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
printf("%d\t",num[i][j]);
}
printf("\n");
}
|
|