随笔分类 - 数据结构
摘要:1 /* 2 顺序栈的创建 3 4 Levi. 5 */ 6 7 #include <stdio.h> 8 #define DataType char 9 #define StackSize 10010 11 12 typedef struct{13 DataType stack[StackSize];14 int top;15 }SeqStack;16 17 18 void InitStack(SeqStack *S){19 S->top=0;20 }21 22 int StackEmpty(SeqStack S){23 if(S.top==0)24 ...
阅读全文
摘要:1 /* 2 头尾插创建链表。 3 4 */ 5 6 7 #include <stdio.h> 8 #include <stdlib.h> 9 #include "sys/malloc.h"10 11 void CreateList(LinkList *L,int n){12 int i;13 LinkList p;14 *L=(LinkList)malloc(sizeof(struct LNode));15 (*L)->next=NULL;16 printf("Please input Link_len = %d : \n"
阅读全文
摘要:1 /* 2 1.不带头结点的单链表。 3 2.需要修改,有引用在里面,只是伪代码。 4 5 6 Levi. 7 date:2013.1.22 8 */ 9 10 #include <stdio.h> 11 #include "sys/malloc.h" 12 #include <stdlib.h> 13 14 typedef struct LNode{ 15 TypeElem data; 16 struct LNode *next; 17 }; 18 19 typedef struct LNode * LinkList; 20 2...
阅读全文
摘要:1 /* 2 1.带头结点L的单链表结构 3 2.参照严慧敏单链表的链表结构 4 5 Levi 6 date:13.1.22 7 */ 8 9 #include <stdio.h> 10 #include "sys/malloc.h" 11 #include <stdlib.h> 12 #define ElemType int 13 14 15 struct LNode{ 16 ElemType data; 17 struct LNode * next; 18 }; 19 20 typedef struct LNode * LinkLis...
阅读全文
摘要:1 /* 2 1.此方法是看着数据结构李葆春自写的顺序表 3 2.此方法Delete 还没限制i 范围。 4 3.此定义只是用来测试用 5 6 7 Levi. 8 date: 2013.1.21 9 */ 10 #include <stdio.h> 11 #define ElemType int 12 #define MAX_LEN 20 13 14 typedef struct { 15 ElemType data[MAX_LEN]; 16 int len; 17 }SqList; 18 19 20 void Print(SqL...
阅读全文
摘要:vector 顺序表操作1#include <iostream>using namespace std;#include <vector>using std::vector;#define MAX 100vector<int>ivec(MAX);vector<int>::iterator it;int len;void Output(){ int i; for (i=0;i<len;i++) { cout<<ivec[i]<<" "; } cout<<endl;} int main()
阅读全文
摘要:Description对于任意十进制数转换为k进制,包括整数部分和小数部分转换。整数部分采用除k求余法,小数部分采用乘k取整法例如x=19.125,求2进制转换整数部分19,小数部分0.12519 / 2 = 9 … 10.125 * 2 = 0.25 … 09 / 2 = 4 … 10.25 * 2 = 0.5 … 04 / 2 = 2 … 00.5 * 2 = 1 … 12 / 2 = 1 … 01 / 2 = 0 … 1所以整数部分转为 10011,小数部分转为0.001,合起来为10011.001 请用堆栈实现上述数制转换Input第一行输入一个t,表示下面将有t组测试数据。接下...
阅读全文
摘要:#include <iostream>#include <string>#include <queue>#include <set>using namespace std;#define MaxLen 100int main(){ set<int> group[MaxLen]; queue<int> subgroupQueue[MaxLen]; queue<queue<int>*> totalQueue; int cases; cin>>cases; for(int i=0;i<c
阅读全文
摘要:Description假定两个顺序表的数据已经按照从小到大的顺序排列,实现两个顺序表的合并Input第一行输入n表示顺序表A包含的·n个数据第二行输入n个数据,数据是小于100的正整数第三行输入m表示顺序表B包含的·n个数据第二行输入m个数据,数据是小于100的正整数Output输出合并后的顺序表内的所有数据,数据之间用空格隔开Sample Input311 33 55422 44 66 88Sample Output11 22 33 44 55 66 88 #include <stdio.h> #include <malloc.h> typedef
阅读全文
摘要:Description实现顺序表的创建、插入、删除、查找Input第一行输入顺序表的实际长度n第二行输入n个数据第三行输入要插入的新数据和插入位置第四行输入要删除的位置第五行输入要查找的位置Output第一行输出创建后,顺序表内的所有数据,数据之间用空格隔开第二行输出执行插入操作后,顺序表内的所有数据,数据之间用空格隔开第三行输出执行删除操作后,顺序表内的所有数据,数据之间用空格隔开第四行输出指定位置的数据Sample Input611 22 33 44 55 66888 352Sample Output11 22 33 44 55 66 11 22 888 33 44 55 66 11 22
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>#define STACK_SIZE 100 #define overflow -2#define OK 1#define TRUE 1#define FALSE 0typedef char datatype; typedef int Status; typedef struct {datatype *base; datatype *top; int stacksize; } seqstack; void Initial(seqstac...
阅读全文

浙公网安备 33010602011771号