
数据结构
文章平均质量分 78
「已注销」
这个作者很懒,什么都没留下…
展开
-
快速排序
//快速排序 #include using namespace std; #include //计算排序时间 typedef int T; void sort (T a[], int n)//(T* a, int n) { if(n<=1) return; swap(*a, a[n>>1]); T* L=a+1; T* R=a+n-1; T v=*a; while(L<R) {原创 2014-07-10 10:46:24 · 293 阅读 · 0 评论 -
链表操作
#include using namespace std; //链表的定义 typedef int T; class List { struct Node { T data; Node* next; Node (const T & t=T()):data(t) {next=NULL;} }; Node* head; public : List(): head (NULL) {} void cle原创 2014-07-10 10:25:21 · 276 阅读 · 0 评论 -
单链表的逆置
#include #include struct node { int data; struct node *m_pNext; }; typedef struct node * PNode;//PNode相当于node* /*递归版 PNode reverseList(PNode head) { if(head == NULL || head->m_pNext =原创 2014-07-10 14:12:31 · 384 阅读 · 0 评论 -
已知二叉树的先序遍历和中序遍历序列,输出后序遍历序列
#include #include const int N=20; char s1[N], s2[N], ans[N]; void build(int n, char* s1, char* s2, char* s) { if(n <= 0) return; int p = strchr(s2, s1[0]) - s2;//strchr----找到s1[0]在s2中的位置 build(p,原创 2014-07-08 22:38:14 · 7882 阅读 · 0 评论 -
[排序]快速排序
#include int Partition(int *iArray, int i, int j) { int pivot = iArray[ i ]; while(i < j) { while(i = pivot ) { j --; } if(i < j) { iArray[ i ++ ] = iArray[ j ]; } while(i原创 2014-09-02 09:22:39 · 314 阅读 · 0 评论