Update 例1.cpp
This commit is contained in:
parent
bb139ef419
commit
f03eafdfe8
@ -1,17 +1,17 @@
|
||||
//函数模板参数可以是类属参数,也可以包括普通类型的参数
|
||||
//函数模板参数可以是类属参数,也可以包括普通类型的参数
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
template <class T>
|
||||
//实现降序
|
||||
//实现降序
|
||||
void sort(T &a, int n){
|
||||
for (int i=0;i<n;i++){
|
||||
int p=i;
|
||||
for (int j=i;j<n;j++)
|
||||
if(a[p]<a[j])
|
||||
p=j;
|
||||
int t=a[i];
|
||||
T t=a[i];
|
||||
a[i]=a[p];
|
||||
a[p]=t;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user