Update 例1.cpp

This commit is contained in:
GongXiangShun 2020-07-28 10:34:30 +08:00 committed by GitHub
parent bb139ef419
commit f03eafdfe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}