随笔分类 - 数据结构和算法
摘要:这里先删除第2个结点,测试 deleNode 函数 1 /*把第i个结点从链表中删除*/ 2 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 7 //链表中节点的结构 8 typedef struct Link { 9 int data; 10 struct
阅读全文
摘要:这里是在第三个结点之前插入一个值 1 /*在特定(第三个结点)结点之前插入元素*/ 2 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 7 //链表中节点的结构 8 typedef struct Link { 9 int data; 10 struct Li
阅读全文
摘要:/*求表长*/ #include<stdio.h> #include<stdlib.h> //链表中节点的结构 typedef struct Link { int data; struct Link* next; }link; //链表初始化 link* initLink(link* phead)
阅读全文
摘要:1,首先将链表初始值改为用户的输入 2,根据用户的输入,打印出初始化后的链表 3,用户继续输入希望寻找的值 4,根据这个值在链表中寻找数据域是这个值的结点,并计数,最后返回满足条件的结点个数 1 /*返回特定数据域值的结点个数*/ 2 3 #include<stdio.h> 4 #include<s
阅读全文
摘要:根据用户输入的号码,找到这个号码对应的值 1 /*按号定位*/ 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 6 //链表中节点的结构 7 typedef struct Link { 8 int data; 9 struct Link* next; 10
阅读全文
摘要:根据用户输入的元素,查找这个元素在链表中是第几个 1 /*按值定位*/ 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 6 //链表中节点的结构 7 typedef struct Link { 8 int data; 9 struct Link* next;
阅读全文
摘要:1,创建尾指针的方式,让尾指针不断往前移动 1 /*头插入创建单链表*/ 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 6 typedef struct Link { 7 int data; 8 struct Link* next; 9 }link; 10
阅读全文
摘要:1,使用头指针的方式,不创建头结点 1 /*尾插入实现方法2*/ 2 #include<stdio.h> 3 #include<stdlib.h> 4 5 //链表中节点的结构 6 typedef struct Link { 7 int data; 8 struct Link* next; 9 }l
阅读全文
摘要:1,创建单链表,用尾插入法给单链表赋初始值,并打印出链表的全部数据 1 /*尾插入法 2 创建单链表 3 */ 4 5 6 #include<stdio.h> 7 #include<stdlib.h> 8 9 //链表内存结构 10 typedef struct LinkList { 11 int
阅读全文
摘要:1 #include<stdio.h> 2 #include<math.h> 3 struct Complex { 4 double a;//实部 5 double b;//虚部 6 }; 7 void initComplex(double x, double y) { 8 printf("%.2f
阅读全文
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Capacity1 10 4 #define Capacity2 5 5 struct List { 6 int* ElemSet; 7 int len; 8 int capacity; 9 }li
阅读全文
摘要:操作步骤: 1,求两个线性表的长度 2,从线性表LB中依次察看每个数据元素:GetElem(LB,i) -> e 3,依次在线性表LA中进行查仿:LocateElem(LA,e, equal()) 4,若不存在,则插入之。ListInsert(LA,n+1, e) 1 #include<stdio.
阅读全文
摘要:顺序表基本操作实现 1 #include<stdio.h> 2 #define Capacity 5 3 4 //自定义顺序表 5 struct List{ 6 int* ElemSet;//声明了一个名为ElemSet的长度不确定的数组,也叫“动态数组” 7 int len; //顺序表的长度 8
阅读全文

浙公网安备 33010602011771号