#include "stdafx.h"
#include <iostream>
using namespace std;
void BubbleSort(int data[],int length)
{
int i,j;
bool exchange=false;
for(int i=0;i<length-1;i++)
{
exchange=false;
for(int j=0;j<length-i-1;j++)
{
if(data[j+1]<data[j])
{
int temp=data[j+1];
data[j+1]=data[j];
data[j]=temp;
exchange=true;
}
}
if(!exchange)
return;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int data[10]={1,4,7,0,6,10,3,8,2,9};
BubbleSort(data,10);
cout<<"After BubbleSort:"<<endl;
for(int i=0;i<10;i++)
cout<<data[i] <<" ";
cout<<endl;
return 0;
}