随笔分类 - 数据结构
摘要:Binary Tree: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 typedef char Elemtype; 5 6 typedef struct BTNode 7 { 8 Elemtype data; 9 struct BTNode *lch
阅读全文
摘要:1 //双亲孩子表示法 2 #define MAX_TREE_SIZE 100 3 4 typedef char ElemType; 5 6 //孩子结点 7 typedef struct CTNode 8 { 9 int child; //孩子结点的下标 10 struct CTNode *nex
阅读全文
摘要:KMP:一种模式匹配算法 重点:next数组:长度就是模式子串的长度 next[i]的值是若第i个位置不匹配则下一个要进行匹配的首地址 重点理解前缀后缀:例如:abcabc的最长前缀abc,后缀abc, aaaa的前缀是aaa(aaaa就没有意义了)后缀是aaa. 分析:j值回溯:j返回到前一个失配
阅读全文
摘要:1 //八皇后:递归 2 #include <stdio.h> 3 4 int count=0; 5 //判断第row行第column列有没有危险:可以存放Queen? 6 //int (*chess)[8]:指向某一行的指针,8表示列数 7 int notDanger(int row,int co
阅读全文
摘要:思路: 1 #include <stdio.h> 2 //将n个盘子从x借助y移动到Z 3 void move(int n,char x,char y,char z) 4 { 5 if(n==1) 6 printf("%c-->%c\n", x, z); 7 else 8 { 9 move(n -
阅读全文
摘要:递归函数:调用自身的函数称为递归函数 1 #include <stdio.h> 2 void print() 3 { 4 char a; 5 scanf("%c", &a); 6 if(a!='#') 7 print(); 8 if(a!='#') 9 printf("%c", a); 10 } 1
阅读全文
摘要:1 //斐波那契数列的递归和迭代实现 2 #include <stdio.h> 3 4 //迭代实现 5 int main() 6 { 7 int i; 8 int a[40]; 9 10 a[0] = 0; 11 a[1] = 1; 12 printf("%d %d ", a[0],a[1]);
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 typedef char ElemType; 5 typedef struct QNode 6 { 7 ElemType data; 8 struct QNode *next; 9 } QNode, *Qu
阅读全文
摘要:1. 2. 3. 1 //逆波兰表达式 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <ctype.h> 5 6 #define STACK_INIT_SIZE 20 //存储栈的长度,栈大小 7 #define STACKINCREME
阅读全文
摘要:/* 1.会对它进行修改的就以指针的形式传进来,eg:void Push(sqStack *s,ElemType *e) 、void Pop(sqStack *s,ElemType *e) 2.不会修改的只需要传数据就可以了, eg:int StackLen(sqStack s) 3.指针用箭头:s
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #define OK 1 #define ERROR 0 //可以方便的改变元素类型 typedef char ElemType; typedef int Status; typedef struct node{ int
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #define CardNumber 13 typedef struct node{ int data; struct node * next; }sqlist, *linklist; linklist CreateLin
阅读全文
摘要:摘自小甲鱼 #include "stdio.h" #include <stdlib.h> #include <time.h> #define OK 1 #define ERROR 0 #define TRUE 1 #define FALSE 0 typedef int Status;/*Status
阅读全文
摘要:约瑟夫问题: #include <stdio.h> #include <stdlib.h> typedef struct node{ int data; struct node * next; }node; //创建一个有n个结点的循环链表 node * initLink(int n){ node
阅读全文

浙公网安备 33010602011771号