鱼腌一天有亚硝酸盐吗:zuoye作业不要看

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 07:25:33
//请将例4-5的冒泡排序函数改写成为模版函数并编写一个程序进行测试
#include<iostream.h>
template <class T>
void paixu(T *list,int count)
{
int i=0,j=0,tmp;
for(i=0; i<count; i=i+1)
{
for(j=count-1; j>i; j=j-1)
if(list[j-1]>list[j])
{
tmp = list[j-1];
list[j-1] = list[j];
list[j] = tmp;
}
}
for(i=0; i<count; i=i+1)
cout<<list[i]<<"\t"<<endl;
}
void main()
{
int list1[16]=
{
503, 87, 512, 61, 908, 170, 897, 275,
653, 426, 154, 509, 612, 677, 765, 703
};
cout<<"kaishi:"<<"503, 87, 512, 61, 908, 170, "<<endl;
cout<<"897, 275,653, 426, 154, 509, 612, 677, 765, 703"<<endl;
cout<<"paixu hou:"<<endl;
paixu(list1,16);
}