#include<iostream>
using namespace std;
void bubbleSort(int a[],int size);
int main()
{
int array[]={34,65,12,43,67,5,78,10,3,70},k;
int len=sizeof(array)/sizeof(int);
cout<<"The orginal array are:"<<endl;
for(k=0;k<len;k++)
cout<<array[k]<<",";
cout<<endl;
bubbleSort(array,len);
cout<<"The sorted array are:<<endl";
for(k=0;k<len;k++)
cout<<array[k]<<",";
cout<<endl;
system("pause");
return 0;
}
void bubbleSort(int a[],int size)
{
int temp;
for(int pass=1;pass<size;pass++)
{
for(int k=0;k<size-pass;k++)
if(a[k]>a[k+1])
{
temp=a[k];
a[k]=a[k+1];
a[k+1]=temp;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载