30 lines
468 B
C
30 lines
468 B
C
/* test5:冒泡排序(数组访问模拟)*/
|
||
int swap(int i, int j) {
|
||
int temp;
|
||
temp = i;
|
||
i = j;
|
||
j = temp;
|
||
return 0;
|
||
}
|
||
|
||
int main() {
|
||
int a;
|
||
int b;
|
||
int c;
|
||
int d;
|
||
int e;
|
||
a = 5;
|
||
b = 3;
|
||
c = 8;
|
||
d = 1;
|
||
e = 9;
|
||
|
||
/* 冒泡排序模拟 */
|
||
if (a > b) { swap(a, b); }
|
||
if (b > c) { swap(b, c); }
|
||
if (c > d) { swap(c, d); }
|
||
if (d > e) { swap(d, e); }
|
||
|
||
return e;
|
||
}
|