凤凰求蛊
#include <iostream>using namespace std;//从小到大排序template <typename T>void Bubble(T arr[], int n){int i,j;for (i=0; i<n; i++)for (j=0; j<n-i-1; j++){if (arr[j] > arr[j+1]){T temp;temp = arr[j];arr[j] = arr[j+1];arr[j+1] = temp;}}for (i=0; i<n; i++)cout << arr[i] << endl;}//从小到大排序template <typename T>void Insert(T arr[], int n){int i,j,pos;T temp;for (i=0; i<n; i++){pos = i;for (j=i; j<n; j++){if (arr[j] < arr[pos]){pos = j;temp = arr[j];arr[j] = arr[pos];arr[pos] = temp;}}temp = arr[i];arr[i] = arr[pos];arr[pos] = temp;}for (i=0; i<n; i++)cout << arr[i] << endl;}int main(){int i[7] = {2, 234, 234, 12, 1400, 345, 564};float f[7] = {2.9, 234.2, 234.5, 12.73, 1400, 345.2, 564.1};//Bubble(i, 7);Insert(i, 7);cout << endl;//Bubble(f, 7);Insert(f, 7);return 0;}