/*
*冒泡排序法
*/
#include <iostream>
using namespace std;
int main(){
int a[10];
int i, j, temp;
cout << "输入10个整数:\n";
for(i=0; i<10; i++){
cin >> a[i];
}
/*排序*/
for(i=0; i<9; i++){
for(j=0; j<9-i; j++){
if(a[j]>a[j+1]){
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
cout << "//-----------------------------------//" << endl;
for(i=0; i<10; i++){
cout << a[i] << '\t';
}
cout << endl;
return 0;
}
冒泡排序法
最新推荐文章于 2024-08-15 06:00:00 发布