北邮数据结构
6-Tong
a super student in BUPT!
展开
-
OJ9-2 B.KMP 附测试样例
#include <stdio.h>#include <stdlib.h>#include <string.h>int KMP(char a[], char key[], int index, int next[]);int main(){ char *a; char *key; a = malloc(sizeof(char) * 220); key = malloc(sizeof(char) * 22); //防止第一.原创 2020-12-09 17:21:35 · 1182 阅读 · 0 评论 -
子串匹配 BF法
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char a[202]; char key[22]; gets(a); gets(key); int length; length = strlen(key); int i, j; i = 0; j = 0; while (a[i] != '\原创 2020-12-05 21:45:49 · 203 阅读 · 0 评论 -
OJ 9-1 A. Minimum Spanning Tree
#include <stdio.h>#include <stdlib.h>#define inf 1e9void aDist(int a[11][11], int dist, int i, int j);struct table;typedef struct table *Table;struct table{ int x; int known; int dist; int lastVex;};void dijkstra(Tab.原创 2020-12-04 18:40:21 · 578 阅读 · 0 评论 -
OJ8-3 C. Slack Time 松弛时间
C. Slack Time运行时间限制: 1000 运行内存限制: 65536作者: scsxuke 是否specialjudge: False题目描述Given an Acyclic Graph as the figure (shared by QQ), delete one edge of activity, then calculate the slack time of the left nodes.Output the slack time of a specified nodeinp原创 2020-12-01 17:46:00 · 1239 阅读 · 1 评论 -
OJ 8-2 B. DFS 深度优先算法 C语言
#include <stdio.h>void to1(int a[10][10], int i, int j);void DFS(int a[10][10], int flag[], int start);int main(){ int a[10][10]; int flag[10]; for (int i = 1; i <= 8; i++) { flag[i] = 0; } for (int i = 1; i &.原创 2020-11-30 17:02:25 · 494 阅读 · 0 评论 -
OJ8-1 A. 最短路径-迪杰斯特拉算法 dijkstra C语言
#include <stdio.h>#include <stdlib.h>struct table;typedef struct table *Table;struct table{ int x; int known; int dist; int lastVex;};#define inf 1e9void dijkstra(Table T[8], int a[8][8]);void printPath(int end, Tab.原创 2020-11-30 17:01:04 · 762 阅读 · 0 评论 -
邻接矩阵 拓扑排序OJ7-2 B. 拓扑排序
#include <stdio.h>int Index(char x, char name[]);int inDgree(int j, int a[11][11]);int main(){ char name[11] = { 'S', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'.原创 2020-11-20 22:17:22 · 706 阅读 · 0 评论 -
十字链表 朋友圈点赞问题 OJ7-1 A. 朋友圈点赞
#include <stdio.h>#include <stdlib.h>struct arcBox;typedef struct arcBox *ptrtoArc;struct arcBox{ int from; int to; ptrtoArc nextInArc; ptrtoArc nextOutArc;};struct vexBox;typedef struct vexBox *ptrtoVex;struct vexBo.原创 2020-11-20 22:15:15 · 642 阅读 · 1 评论 -
OJ6-2 B. selection sort
B. selection sort#include <stdio.h>#include <stdlib.h>void selectionSort(int a[], int n);int main(){ int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d,", &a[i]); } se原创 2020-11-19 23:49:13 · 250 阅读 · 0 评论 -
作业-3.26 Dequeue 双端队列
3.26 双端队列是由一些项的表组成的数据结构,对该数据结构可以进行下列操作:原创 2020-11-19 17:18:48 · 564 阅读 · 0 评论 -
OJ6-3 C. radix sort
C. radix sort题目描述radix sortGiven a sequence of numbers seperated by comma, you should sort them by radix sort.Output the step result of each passinput2 linethe first line is a sequence of numbers(<20) seperated by comma;the second is the step pas原创 2020-11-18 17:18:24 · 668 阅读 · 3 评论 -
OJ6-1 A. quick sort
A. quick sort#include <stdio.h>#include <stdlib.h>#define cutoff 3void insertSort(int a[], int left, int right);void Qsort(int a[], int left, int right);int mid3(int a[], int left, int right);void swap(int *a, int *b);int main(){原创 2020-11-13 20:34:35 · 574 阅读 · 0 评论 -
OJ5-3 C. Heap Sort
C. Heap Sort输入样例:31,41,59,26,53,58,97,2#include <stdio.h>#include <stdlib.h>void percolateDown(int a[], int top, int p);int main(){ int a[200]; char b[200]; int x = 0; int top = 0; gets(b); for (int i = 0; b原创 2020-11-13 08:42:02 · 280 阅读 · 0 评论 -
OJ5-2 B. Shell sort
输入样例文字版:1049,38,65,97,76,13,27,50,2,8,#include <stdio.h>#include <stdlib.h>void shellSort(int a[], int n);int main(){ int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d,", &..原创 2020-11-11 11:39:18 · 360 阅读 · 0 评论 -
OJ5-1 A. Insertion sort
A. Insertion sort37,3,1,#include <stdio.h>#include <stdlib.h>void insertSort(int n, int a[]);int main(){ int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d,", &a[i]); }原创 2020-11-11 11:05:41 · 281 阅读 · 0 评论 -
OJ4-A A. Binary Heap
#include <stdio.h>#include <stdlib.h>struct heap;typedef struct heap *priorityQueue;struct heap{ int capacity; int top; int *array;};void insert(int x, priorityQueue H);void percolateDown(int p, priorityQueue H);int main().原创 2020-11-09 14:03:02 · 317 阅读 · 0 评论 -
OJ4-B B. Binomial Queues
#include <stdio.h>#include <stdlib.h>#include <math.h>struct Node;typedef struct Node *position;typedef struct Node *tree;typedef struct collection *queue;struct Node{ int x; position left, next;};struct collection{.原创 2020-11-09 14:03:11 · 414 阅读 · 0 评论 -
OJ2-3 C. 哈夫曼树解码
#include <stdio.h>#include <stdlib.h>#define leaf 1struct Node;typedef struct Node *ptrtoNode;typedef ptrtoNode position;typedef ptrtoNode tree;struct Node{ char x; position left, right; int kind;};int main(){ tree .原创 2020-10-23 21:35:44 · 530 阅读 · 0 评论 -
OJ2-2 AVL
题目描述:inserting some numbers into an initially empty AVL tree.Show AVL tree in preorder.#include <stdio.h>#include <stdlib.h>struct Node;typedef struct Node *ptrtoNode;typedef ptrtoNode position;typedef ptrtoNode tree;struct Node{原创 2020-10-23 17:21:01 · 766 阅读 · 0 评论 -
OJ2-1 A. binary search tree
#include <stdio.h>#include <stdlib.h>struct Node;typedef struct Node *ptrtoNode;typedef ptrtoNode position;typedef ptrtoNode tree;struct Node{ int x; position left, right;};tree insert(int x, tree T);int main(){ int num,原创 2020-10-23 17:16:52 · 461 阅读 · 0 评论 -
OJ3-3 C. How to place the mails
#include <stdio.h>#include <stdlib.h>#include <math.h>#define full 1#define empty 0#define delete 2struct Node;typedef struct Node *ptrtoNode;typedef ptrtoNode position;struct Node{ long long x; int kind;};void inser.原创 2020-10-30 08:37:00 · 300 阅读 · 0 评论 -
OJ3-2 B. Hash Table
B. Hash Table运行时间限制: 1000 运行内存限制: 65536作者: scsxuke 是否specialjudge: False题目描述Create a hash table (Open Addressing) from the given sequence and output the Londing Density and Average Search Time (AST). The hash function is H(key)= key % 13 and use linear原创 2020-10-30 08:36:40 · 120 阅读 · 0 评论 -
OJ3-1 A. Preorder
A. Preorder运行时间限制: 1000 运行内存限制: 65536作者: scsszhangxi 是否specialjudge: False题目描述题目描述Create an expression tree from a given postfix expression, then traverse that tree by preorder. At last, you are asked to ouput all the nodes by preorder.输入格式1 line.A原创 2020-10-30 08:35:20 · 223 阅读 · 0 评论 -
OJ4-D. Balancing Symbols
Balancing Symbols时间限制1000 ms 内存限制65536 KB题目描述Balancing symbols: Check if parenthesis ( ), brackets 【】, and braces {} are balanced.输入格式An expression includes variables and symbols. The max length is 50.输出格式1 line.If all the (, 0 and {} are balanced,.原创 2020-10-18 00:12:01 · 952 阅读 · 0 评论 -
OJ3-C. central list
题目描述If a list is central symmetry, it is called a central list. for example, 1->3->5->7->9->7->5->3->1 is a central list.Give you a sequence of numbers, form a link list and then judge whether it is a central list.Input, a sequen原创 2020-10-18 00:12:13 · 1205 阅读 · 0 评论 -
OJ2--B. Infix to Postfix Conversion
Infix to Postfix Conversion时间限制1000 ms 内存限制65536 KB题目描述Convert the infix expression to postfix expression输入格式1 lineA correct expression include +.一.*./ ,(,) and interger. Each integer is less than 10 and more than 0.输出格式2 line.The first line give.原创 2020-10-18 00:12:24 · 1035 阅读 · 0 评论 -
OJ-1--A. Who is the last?
Who is the last?时间限制1000 ms 内存限制65536 KB题目描述There are N people, numbered from 1 to N, sitting around in a circle. Counted from the NO.1, the M th people should leave the game.loop will go on. After several loops, there will be only on guy left. Writin.原创 2020-10-18 00:12:34 · 922 阅读 · 0 评论 -
北邮数据结构第二次作业--3.10 用环形链表实现约瑟夫环
#include <stdio.h>#include <stdlib.h>typedef struct Node *ptrToNode;typedef ptrToNode Head;typedef ptrToNode Position;struct Node{ int x; Position next;};int main(){ // 函数的声明 Head create(int people); void delete原创 2020-09-26 09:44:54 · 235 阅读 · 0 评论 -
北邮数据结构第二次作业--3.12 链表的反转
3.12编写一个非递归过程以O(N)时间反转单链表#include <stdio.h>#include <stdlib.h>typedef struct Node *ptrToNode;typedef ptrToNode Head;typedef ptrToNode Position;struct Node{ int x; Position next; /* data */};Head reverse(Head head){ Posi原创 2020-09-26 09:43:12 · 210 阅读 · 0 评论 -
北邮数据结构第二次作业--3.6 用链表实现多项式相加
#include <stdlib.h>#include <stdio.h>typedef struct Node *ptrToNode;typedef ptrToNode Position;typedef ptrToNode Head;/*总体思路:加入两个多项式分别为p1、p2,则先按顺序遍历p1中的指数,如在p1中的某项中的指数是exp,则在p2中查找是否有exp,如果有,则把系数合并,并放入p3,且把多项式p2中的此项的flag标记为1(找到了)如果p2中没有e原创 2020-09-26 09:32:43 · 942 阅读 · 0 评论