#include<iostream>
using namespace std;
void exchange(int& a, int& b) {
int temp = a;
a = b;
b = temp;
return;
}
int main()
{
int a[5] = { 12,35,99,18,76 };
int i, j;
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4 - i; ++j) {
if (a[j] < a[j + 1]) {
exchange(a[j], a[j + 1]);
}
}
}
for (i = 0; i < 5; ++i) {
cout << a[i] << endl;
}
return 0;
}
拾遗冒泡排序
最新推荐文章于 2024-07-22 23:59:01 发布