#include"iostream"
using namespace std;
void Swap(int& a1,int& a2)
{
int t;
t =a1;
a1 =a2;
a2 =t;
}
void bubblesort(int A[],int n)
{
for(int i=0;i<n;i++)
for(int j=0;j<n-i;j++)
{
if(A[j]>A[j+1])
Swap(A[j],A[j+1]);
}
for(i=0;i<=n;i++)
cout<<A[i]<<" ";
cout<<endl;
}
void main()
{
int A[10] ={2,4,1,7,0,-1,5,8,9,3};
bubblesort(A,9);
}
基本排序之冒泡排序
最新推荐文章于 2023-08-20 22:45:20 发布