要求:可以对不同类型的数组进行排序,从大到小排列
排序算法:分别是冒泡排序和选择排序
测试:char数组和int数组
#include <iostream>
#include <string>
using namespace std;
//面向对象编程、泛型编程
template <typename T>
void myswap(T& a, T& b) {
T temp = a;
a = b;
b = temp;
}
template <typename T>
//void mysort(T& arr, int len) {//冒泡排序法
// for (int i = 0; i < len-1; i++) {
// for (int j = 0; j < len - 1 - i; j++) {
// if (arr[j] < arr[j + 1]) {