随笔分类 - 数据结构_作业集
摘要:Problem Description: 双十一大家都在买买买,可忙坏了快递小哥了。zl和皮卡鸡在大伙在剁手的时候,偷偷去快递公司那当兼职赚钱了。zl将箱子一个个叠起来,皮卡鸡将那堆箱子搬到别的地方去,但由于箱子太重,他每次只能拿最上面的一个。zl一边叠箱子,皮卡鸡就一边把目前最上面的箱子搬走,但由
阅读全文
摘要:Problem Description: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出
阅读全文
摘要:Problem Description: Problem Description: Input: 输入包含多组数据(EOF),每组数据第一行是一个整数n(1<=n<=10^5),第二行有n个整数(<=10^5); Input: Output: 对于每组数据,输出小明排序算法的交换次数。 Output
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int len = 20;//待排序数组元素的个数,下标从1开始 6 //1、冒泡排序 7 void Bubble_sort(int s[],int len){ 8 bool flag; 9 for(int i=1;i...
阅读全文
摘要:1 //算法6.8 普里姆算法 2 #include 3 using namespace std; 4 5 typedef char VerTexType; 6 typedef int ArcType; 7 #define MVNum 100 8 #define MaxInt 32767 //表示极大值,即∞ ...
阅读全文
摘要:Problem Description: 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input: 共有若干行,每行一个正整数N≤12,表示棋盘和皇后的
阅读全文
摘要:括号匹配(栈) 括号匹配(栈) Time Limit: 2000/1000ms (Java/Others) Time Limit: 2000/1000ms (Java/Others) Problem Description: 给一组包含[]()两种括号的序列,检查是否是合法的。 如:()[],([]
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 #define OK 1 5 #define OVERFLOW -2 6 typedef int status; 7 typedef struct BiTNode{ //创建链表 8 char data; //节点的值 9 struct BiTN...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 #define OK 1 5 #define ERROR 0 6 #define OVERFLOW -2 7 #define MAXQSIZE 100 8 typedef int QElemType; 9 typedef int Status; 10 typedef...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 //顺序栈定义 6 #define OK 1 7 #define ERROR 0 8 #define OVERFLOW -2 9 #define MAXSIZE 100 10 typedef int Status; 11 typedef char SElemType; 12 t...
阅读全文
摘要:Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCI
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 #define OK 1 6 #define ERROR 0 7 typedef int Status; 8 9 typedef struct LNode 10 { 11 int data; //结点的数据域 12 struct L...
阅读全文
摘要:1 #include 2 using namespace std; 3 4 #define OK 1 5 #define ERROR 0 6 #define OVERFLOW -2 7 typedef int Status; //Status 是函数返回值类型,其值是函数结果状态代码。 8 typedef int ElemType; //E...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 #define OK 1 5 #define ERROR 0 6 #define OVERFLOW -2 7 typedef int Status; //Status 是函数返回值类型,其值是函数结果状态代码。 8 typedef int ElemType; ...
阅读全文
摘要:帮挂科 帮挂科 Time Limit: 2000/1000ms (Java/Others) 64bit IO Format: %lld & %llu Time Limit: 2000/1000ms (Java/Others) 64bit IO Format: %lld & %llu Problem
阅读全文