摘要: 下面代码仅供本人复习数据结构所用,实用性N低,各位飘过吧~~哈哈:>//// C++ 模版技术实现直接选择排序. // #include <cstdlib>#include <cstring> #include <iostream>//// 首先在未排序序列中找到最小元素,存放到排序序列的起始位置,// 然后,再从剩余未排序元素中继续寻找最小元素,// 然后放到排序序列末尾. 以此类推,直到所有元素均排序完毕.//template <typename T>void selectionSort(T *array, const size_t c 阅读全文
posted @ 2011-05-27 23:33 Atypiape 阅读(975) 评论(0) 推荐(0) 编辑
摘要: 下面代码仅供本人复习数据结构所用,实用性N低,各位飘过吧~~哈哈:>//// C++模版技术实现鸡尾酒排序(改进的冒泡排序). // #include <cstdlib>#include <cstring>#include <iostream>template <typename T>void swap(T &x, T &y){ T temp = x; x = y; y = temp;}template <typename T>void cocktailSort(T *array, const size_t co 阅读全文
posted @ 2011-05-27 21:31 Atypiape 阅读(885) 评论(0) 推荐(0) 编辑
摘要: 下面代码仅供本人复习数据结构所用,实用性N低,各位飘过吧~~哈哈:>//// C++模版技术实现冒泡排序. // #include <cstdlib>#include <cstring>#include <iostream>template <typename T>void bubbleSort(T *array, size_t count){ size_t i, j; bool isSwap; T temp; // // count 个泡泡共需比较 count - 1 趟. // 每趟从最底层 array[count - 1] 开始比较. 阅读全文
posted @ 2011-05-27 20:37 Atypiape 阅读(679) 评论(0) 推荐(0) 编辑
摘要: 下面代码仅供本人复习数据结构所用,实用性N低,各位飘过吧~~哈哈:>//// C++ 模版技术实现简单二叉树. //#include <cstdlib>#include <cstring>#include <iostream>// 二叉树类模版前置声明template <typename T> class BinaryTree; //// 二叉树节点类模版. //template <typename T>class Node{ friend class BinaryTree<T>;private: T _data; 阅读全文
posted @ 2011-05-27 17:34 Atypiape 阅读(2451) 评论(0) 推荐(0) 编辑
摘要: 下面代码仅供本人复习数据结构所用,实用性N低,各位飘过吧~~哈哈:>//// C++ 模版技术实现简单链式栈. // #include <cstdlib>#include <iostream>#include <iomanip>#include <stdexcept>// 链式栈类模版前置声明.template <typename T> class LinkedStack; //// 链式栈节点类模版. // template <typename T>class Node{ friend class LinkedSt 阅读全文
posted @ 2011-05-27 00:44 Atypiape 阅读(1250) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示