随笔分类 - 考试_数据结构_模板
摘要:其实就是单链表的首位相连,不过需要注意的是链表需要注意这个头插法的尾节点应该插在第二个 然后需要注意的是,在删除的时候,我一般是用前后两节点进行扫描,然后前面那个一旦符合我要删除的条件,那么我就把后面那个指向前面那个的下一个。然后把前面的那个地址释放掉,然后用后一个指向的地址给前一个就实现了移动。
阅读全文
摘要:#include #include #include #include using namespace std; struct sqlist{ int *elem; int length; }; void creat(sqlist &a){ a.elem=(int *)malloc(sizeof(int)); int n,tmp; scanf("%d",&n); for ...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Qnode{ int data; Qnode *next; }Qnode,*QueuePtr; typedef struct{ QueuePtr fronts; QueuePtr rear; }LinkQueue; void cre...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct sqstack{ int *base; int *top; int sizestack; }sqstack; void creat_stack(sqstack &a){ a.base=(int*)malloc(100*sizeof(...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct sqstack{ char *base; char *top; int stacksize; }sqstack; void creat_stack(sqstack &a){ a.base=(char *)malloc(100*sizeo...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Lnode { int data; Lnode *next; } Lnode,*linklist; void creat_back(linklist &a) { int n,tmp; linklist p,q; a...
阅读全文
摘要:#include #include using namespace std; void shellsort(int a[],int n){ int i,j; int jump=n; do{ jump=jump/3+1;//浮动 for (i=jump+1;i0 && a[0]1); } int main(){ int a[100]; int n; ...
阅读全文
摘要:#include #include #include #include using namespace std; int temp[100]; int num=0; void Merge(int a[],int left,int mid,int right){ int i=left,j=mid+1,n=0,length=right-left; while(ia[j]){ ...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct { int *top; int *base; int stack_size; }stacks; void creat_stack(stacks &a){ a.base=(int *)malloc(100*sizeof(int)); a...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Lnode { int data; Lnode *next; } Lnode,*linklist; void creat_h(linklist &L) //头插法 { linklist s; int n,tmp; ...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Lnode{ int data; Lnode *next; }Lnode,*linklist; void creat_h(linklist &L){//头插法 linklist s; int n,tmp; L=(linkli...
阅读全文
摘要:#include #include #include #include #include #include #include using namespace std; typedef struct BinTreeNode { char data; struct BinTreeNode *lchild; struct BinTreeNode *rchild; ...
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct BIT_Node{// char data; struct BIT_Node *lchild; struct BIT_Node *rchild; }BIT_Node,*BITree; char ch; void CreateBiTree(BI...
阅读全文
摘要:#include #include #include #include #include using namespace std; typedef struct node { int data; struct node *next;//指向类型完全相同的指针 int len; } Lnode,*Linklist; //一个是结构体类型,一个是结构体指针类型 int n,t...
阅读全文

浙公网安备 33010602011771号