keep it simple, stupid

导航

2011年8月12日 #

常见排序算法

摘要: /*插入排序*/#include <iostream>using namespace std;template <class T>void SWAP(T &x, T &y){ T t; t = x; x = y; y = t;}template <class T>void Insert(T a[], int n, const T x){ int i; for (i = n-1; i >= 0 && x < a[i]; i--) { a[i+1] = a[i]; } a[i+1] = x;}template < 阅读全文

posted @ 2011-08-12 16:31 tujiaw 阅读(164) 评论(0) 推荐(0)

类模板之单链表

摘要: // Chain.h#ifndef _CHAIN_H_#define _CHAIN_H_template<class T>class ChainNode{public: T data; ChainNode<T> *link;};template<class T>class Chain{public: Chain(); ~Chain(); bool IsEmpty() const; int Length() const; bool Find(int index, T &value) const; int Search(T value) const; C 阅读全文

posted @ 2011-08-12 16:02 tujiaw 阅读(154) 评论(0) 推荐(0)