摘要:
#ifndef INSERT_SORT_H#define INSERT_SORT_H#include<assert.h>template<class T,int n>void swap(T* s,int i,int j){ assert((i<n)&&(j<n)); T temp=s[i]; s[i]=s[j]; s[j]=temp;}template<class T,int n>void insert_sort(T* s){ int i=1,j; for(i=1;i<n;i++) for(j=i;j>0;j--) { 阅读全文
摘要:
#ifndef SELECT_SORT_H#define SELECT_SORT_H#include<assert.h>template<class T,int n>void swap(T* s,int i,int j){ assert((i<n)&&(j<n)); T temp=s[i]; s[i]=s[j]; s[j]=temp;}template<class T,int n>T get_smalllest(T* s,int i){ assert(i<n); T result=i; for(;i+1<n;i++) 阅读全文