![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构作业
zig-zag
这个作者很懒,什么都没留下…
展开
-
hdu1176
#include<bits/stdc++.h>#define LL long long#define GG long long#define For(i, j, k) for(int i=j; i<=k; i++)#define Dow(i, j, k) for(int i=j; i>=k; i--)using namespace std;inline GG read() { GG x = 0, f = 1; char ch = getchar(); .原创 2021-05-26 19:43:10 · 58 阅读 · 0 评论 -
pta7-4 最短路径算法(Floyd-Warshall) (20 分)
在带权有向图G中,求G中的任意一对顶点间的最短路径问题,也是十分常见的一种问题。解决这个问题的一个方法是执行n次迪杰斯特拉算法,这样就可以求出每一对顶点间的最短路径,执行的时间复杂度为O(n3)。 而另一种算法是由弗洛伊德提出的,时间复杂度同样是O(n3),但算法的形式简单很多。在本题中,读入一个有向图的带权邻接矩阵(即数组表示),建立有向图并使用Floyd算法求出每一对顶点间的最短路径长度。输入格式:输入的第一行包含1个正整数n,表示图中共有n个顶点。其中n不超过50。以.原创 2021-05-19 19:15:10 · 2075 阅读 · 0 评论 -
pta KMP算法
函数get_nextval(char T[], int nextval[])是计算字符串T的next数组,函数Index_KMP(char S[], char T[], int pos, int next[])是KMP算法。函数接口定义:void get_nextval(char T[], int next[]);int Index_KMP(char S[], char T[], int pos, int next[]);其中T是模式串,S是主串,next是next数组。裁判...原创 2021-04-27 19:39:05 · 2390 阅读 · 1 评论 -
PTA 7-4出栈序列的合法性
https://pintia.cn/problem-sets/1373899177892786176/problems/1373902577301671937给定一个最大容量为M的堆栈,将N个数字按 1, 2, 3, ...,N的顺序入栈,允许按任何顺序出栈,则哪些数字序列是不可能得到的?例如给定M=5、N=7,则我们有可能得到{ 1, 2, 3, 4, 5, 6, 7 },但不可能得到{ 3, 2, 1, 7, 5, 6, 4 }。输入格式:输入第一行给出 3 个不超过 100...原创 2021-04-14 20:36:10 · 351 阅读 · 0 评论 -
PTA 7-26 Windows消息队列
https://pintia.cn/problem-sets/15/problems/841#include<bits/stdc++.h>#define LL long long#define GG int #define For(i, j, k) for(int i=j; i<=k; i++)#define Dow(i, j, k) for(int i=j; i>=k; i--)using namespace std;const int N = 1011; co原创 2021-04-14 20:19:52 · 141 阅读 · 0 评论 -
pta 数据结构6-1
6-1 单链表逆转List Reverse(List L) { PtrToNode Old_head,New_head,Temp; Old_head=L; New_head=NULL; while(Old_head) { Temp=Old_head->Next; Old_head->Next=New_head; New_head=Old_head; Old_head=Temp; }原创 2021-03-31 19:10:54 · 177 阅读 · 0 评论