主观

写出模板函数实现数值型数组元素值按从小到大排序的程序。

#include

using namespace std;

template

void sort(T b[],int n)

{

T temp;

int i,j;

T *a=new T[n];

for (i=0;i

for(i=0;i

{

for(j=i+1;j

{ if(a[i]>a[j])

{temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

for(i=0;i

cout<

delete []a;

}

void main()

{

int i,n=6;

int a[]={5,1,9,10,3,8};

____________;

for(i=0;i

{cout<

cout<

}

参考答案
您可能感兴趣的试题
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服