// b02.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//這是一個(gè)用c++語言寫的冒泡法排序的程序
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int arr[]={8,5,45,35,56,31,4326,7865,6678,43};
int len=sizeof(arr)/sizeof(int);
for(int k=0;k<len-1;k++)
{
for(int j=0;j<len-1;j++)//
{
if(arr[j]>arr[j+1])
{
int tem; //中間變量要使用
tem=arr[j+1];
arr[j+1]=arr[j];
arr[j]=tem;
}
}
}
for(int i=0;i<10;i++)
{
printf("%d\n",arr[i]);
}
return 0;
}