#include<iostream>
using namespace std;
template<typename T>
void bubblesort(T a[],int len)
{
int i,j;
T temp;
for(i=0;i<len-1;i++)
{
for(j=0;j<len-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
void main()
{
double a[]={5.23,2.10,9.88,10.10};
int len=sizeof(a)/sizeof(a[0]);//计算数组长度,sizeof获取了数据在内存中所占用的存储空间,以字节为单位来计数。
bubblesort(a,len);
for(int i=0;i<len;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
int a1[]={58,1,5,96,7,12,55,32,16};
int len1=sizeof(a1)/sizeof(a1[0]);
bubblesort(a1,len1);
for(int j=0;j<len1;j++)
{
cout<<a1[j]<<" ";
}
cout<<endl;
}