冒泡排序
#include <iostream>
using namespace std;
#define N 10
int main(){
int a[N];
int i,j,y,count=0,t;
cout<<"请为数组元素赋初值"<<endl;
for(i=0;i<=N;i++){
cin>>a[i];
}
for(i=0;i<=N-1;i++){
for(j=0;j<=N-1;j++)
if(a[j]>a[i]){
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
cout<<"经过交换后的元素为"<<endl;
for(i=0;i<N;i++){
count++;
cout<<a[i]<<endl;
if(count%5==0){
cout<<endl;
}
cout<<endl;
}
}