PAT:中文_数据结构与算法_习题集
记录习题中的各种问题,供反复考究。
西阿西瓜瓜小花
暂无
展开
-
7-9-旅游规划-编程题
7-9-旅游规划-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#define MAXN 500#define Infinite 65534#define ERROR -1typedef struct WNode Weight;struct WNode { int dist; int cost;}G[MAXN][MAXN];int dist[MAXN], cost[MAXN], visit[MAXN];int N, M, S, D;void I原创 2020-05-09 15:08:01 · 614 阅读 · 0 评论 -
7-8-哈利·波特的考试-编程题
7-8-哈利·波特的考试-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#define MAXN 100#define Infinite 65536int Edge[MAXN][MAXN];int N;typedef enum { false, true } bool;void Initialization(void);void Floyd(...原创 2020-05-05 12:18:58 · 338 阅读 · 0 评论 -
7-7-六度空间-编程题
7-7-六度空间-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#define MAXN 1000#define MAXM (33*MAXN)typedef enum { false, true } bool;int A[MAXN+1][MAXN+1], B[MAXN+1], Q[MAXN+1];int N, front = -1, rear =...原创 2020-04-28 11:07:36 · 272 阅读 · 0 评论 -
7-6-列出连通集-编程题
7-6-列出连通集-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#define MAXN 10int A[MAXN][MAXN], B[MAXN], C[MAXN];int N, front=-1, rear=-1;void DFS(int index);void BFS(int index);void Clear(void);void E...原创 2020-04-27 19:20:07 · 127 阅读 · 0 评论 -
7-5-堆中的路径-编程题
7-5-堆中的路径-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>typedef struct heap* ph;struct heap { int* data; int capable; int size;};ph Creatheap(int N);void InsertMinHeap(p...原创 2020-04-17 17:21:02 · 119 阅读 · 0 评论 -
7-3-树的同构-编程题
7-3-树的同构-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>typedef enum{false,true} bool;typedef struct TNode* Tree;struct TNode { char Data; int Left; int Right;};Tree newT...原创 2020-04-10 20:20:50 · 177 阅读 · 0 评论 -
7-4-是否同一棵二叉搜索树-编程题
7-4-是否同一棵二叉搜索树-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>typedef struct TNode* AVLTree;struct TNode { int Data; AVLTree Left, Right; int Flag;};typedef enum{false,tru...原创 2020-04-10 18:10:46 · 124 阅读 · 0 评论 -
6-12-二叉搜索树的操作集-函数题
6-12-二叉搜索树的操作集-函数题解题代码测试结果问题整理解题代码BinTree Insert(BinTree BST, ElementType X) { if (!BST) { BST = malloc(sizeof(struct TNode)); BST->Data = X; BST->Left = BST->Right = NULL; } else ...原创 2020-04-10 17:06:14 · 169 阅读 · 0 评论 -
6-9-二叉树的遍历-函数题
6-9-二叉树的遍历-函数题解题代码测试结果问题整理解题代码void InorderTraversal(BinTree BT) { if (!BT) return; InorderTraversal(BT->Left); printf(" %c", BT->Data); InorderTraversal(BT->Right); }void PreorderTrav...原创 2020-04-09 21:01:10 · 313 阅读 · 0 评论 -
6-11-先序输出叶结点-函数题
6-11-先序输出叶结点-函数题解题代码测试结果问题整理解题代码void PreorderPrintLeaves(BinTree BT) { if (!BT) return; if (!BT->Left && !BT->Right) printf(" %c", BT->Data); if (BT->Left) PreorderPrintLeaves...原创 2020-04-09 19:34:54 · 286 阅读 · 0 评论 -
6-8-求二叉树高度-函数题
6-8-求二叉树高度-函数题解题代码测试结果问题整理解题代码int GetHeight(BinTree BT) { int max = 1; int a = 1; reGetHeight(BT,&max,a); return max;}void reGetHeight(BinTree BT, int * max, int a) { if (!BT) { *max =...原创 2020-04-04 17:43:25 · 256 阅读 · 0 评论 -
6-2-顺序表操作集-函数题
6-2-顺序表操作集-函数题解题代码测试结果问题整理解题代码List MakeEmpty() { List new = (List)malloc(sizeof(struct LNode)); new->Last = -1; return new;}Position Find(List L, ElementType X) { int ret=ERROR; int i; fo...原创 2020-03-23 14:45:06 · 513 阅读 · 0 评论 -
7-2-一元多项式的乘法与加法运算-编程题
01-复杂度3-二分查找-函数题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>int main(){ int i, j, num1, num2, coef, expon; int a[1001] = { 0 } , sum[1001] = { 0 }, mul[2001] = { 0 }; scanf(...原创 2020-03-23 10:47:31 · 342 阅读 · 0 评论 -
7-52-两个有序链表序列的交集-编程题
7-52-两个有序链表序列的交集-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>typedef struct Node* List;struct Node { int Data; List Next;};List Insert(List t, int num);void Print(List ...原创 2020-03-23 10:23:10 · 251 阅读 · 0 评论 -
7-51-两个有序链表序列的合并-编程题
7-51-两个有序链表序列的合并-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>typedef struct Node* List;struct Node { int Data; List Next;};List Insert(List L, int temp);void Merge(List...原创 2020-03-22 21:34:30 · 272 阅读 · 0 评论 -
7-53-两个有序序列的中位数-编程题
7-53-两个有序序列的中位数-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>int Re(int a[], int left, int right, int K);int main(){ int num, i, j, left, right, t; scanf("%d", &num);...原创 2020-03-22 20:52:46 · 418 阅读 · 0 评论 -
6-4-链式表的按序号查找-函数题
6-4-链式表的按序号查找-函数题解题代码测试结果问题整理解题代码ElementType Len(List L) { ElementType len = 0; while (L) { len++; L = L->Next; } return len;}ElementType FindKth(List L, int K) { ElementType ret = ERR...原创 2020-03-22 20:23:36 · 321 阅读 · 0 评论 -
6-5-链式表操作集-函数题
6-5-链式表操作集-函数题解题代码测试结果问题整理解题代码Position Find(List L, ElementType X) { Position loc = ERROR; if (L) { List t = L; while (t) { if (t->Data == X) { loc = t; break; } else { ...原创 2020-03-22 19:02:19 · 229 阅读 · 0 评论 -
6-7-在一个数组中实现两个堆栈-函数题
6-7-在一个数组中实现两个堆栈-函数题解题代码测试结果问题整理解题代码Stack CreateStack(int MaxSize) { Stack new = (Stack)malloc(sizeof(struct SNode)); new->Data = (ElementType *)malloc(MaxSize * sizeof(ElementType)); new->...原创 2020-03-22 16:30:26 · 271 阅读 · 0 评论 -
6-3-求链式表的表长-编程题
6-3-求链式表的表长-编程题解题代码测试结果问题整理解题代码int Length(List L) { int length = 0; List t = L; while (t) { length++; t = t->Next; } return length;}测试结果问题整理1.这个中文题目集里习惯给不带头结点的链表,有头结点时通常会提示的。...原创 2020-03-22 10:38:08 · 486 阅读 · 0 评论 -
6-6-带头结点的链式表操作集-函数题
6-6-带头结点的链式表操作集-函数题解题代码测试结果问题整理解题代码int Last(List L,List P) { int ret = 1; List last = L; while (last) { if (last->Next == P) { ret = 0; break; } last = last->Next; } return re...原创 2020-03-22 10:31:53 · 276 阅读 · 0 评论 -
6-1-单链表逆转-函数题
6-1-单链表逆转-函数题解题代码测试结果问题整理解题代码List Reverse(List L) { List p = NULL, t = L,temp; while (t) { temp = t->Next; t->Next = p; p = t; t = temp; } return p;}测试结果问题整理1.题目描述的L并没有头结点。...原创 2020-03-22 08:55:39 · 217 阅读 · 0 评论 -
7-1-最大子列和问题-编程题
7-1-最大子列和问题-编程题解题代码测试结果问题整理解题代码#include<stdio.h>int Maxsubsequence(int list[],int left,int right);int Max(int A,int B,int C);int main(){ int n; scanf("%d",&n); int list[n]...原创 2020-03-11 11:58:13 · 225 阅读 · 0 评论 -
6-10-二分查找-函数题
6-10-二分查找-函数题解题代码测试结果问题整理解题代码Position BinarySearch( List L, ElementType X ){ Position left=0,right=L->Last,loc,ret=NotFound; while(left<=right){ loc=(left+right)/2; if...原创 2020-03-11 11:56:51 · 277 阅读 · 0 评论