#include <bits/stdc++.h>
using namespace std;
void bubble(int[],int);
int main(){
int a[10] = {1,2,3,4,5,6,7,8,9,10};
for(int i=0;i<10;++i){
cout << a[i] << " ";
}
cout << endl;
bubble(a,10);
for(int i=0;i<10;++i){
cout << a[i] << " ";
}
return 0;
}
void bubble(int a[],int n){
for(int i=1;i<n;++i){
for(int j=0;j<n-i;++j){
if(a[j]<a[j+1]){
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
bubble冒泡排序,从大往小排函数
分类:函数
时间:2026-01-06 20:53:53
评论留言 (0条)