PAT - 栈、队列、链表

PAT:银行排队问题:队列 题目很长,但思路理清后其实很清晰,无非就是排队。使用STL中的queue。 如果说有什么注意点的话,这题用到了元素为queue的数组,事实上,数组元素还可以是vector、stack等其他数据结构。 代码:#include<stdlib.h> #include<iostream> #include<vector> #include<string> #include<queue> #include 阅读详情

【Codeup 1918】简单计算器

  1. 数据结构node,用来存储操作数和操作符,flag来表示类型
  2. stack操作符栈【遇到相等或者高优先级操作符,弹出】;queue用来存储转换成的后缀表达式;map实现操作符优先级的映射。
  3. 使用(getline(cin, str), str!= "0"),来输入若干字符串str,str = "0",终止输入。
  4. 使用 string::iterator it = it.end(); 由于end的索引是最后一个元素的下一位,要 -1,才有元素,不然会报错。
#include<iostream>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;

struct node {
	double num;
	char op;
	bool flag;
};

string str;
stack<node> s;
queue<node> q;
map<char, int> op;

void Change() {
	double num;
	node temp;
	for (int i = 0; i < str.length();) {
		if (str[i] >= '0' && str[i] <= '9') {
			temp.flag = true;
			temp.num = str[i++] - '0';
			while (i < str.length() && str[i] >= '0' && str[i] <= '9') {
				temp.num = temp.num * 10 + (str[i] - '0');
				i++;
			}
			q.push(temp);
		}
		else {
			temp.flag = false;
			while (!s.empty() && op[str[i]] <= op[s.top().op]) {
				q.push(s.top());
				s.pop();
			}
			temp.op = str[i];
			s.push(temp);
			i++;

		}
	}
	while (!s.empty()) {
		q.push(s.top());
		s.pop();
	}

}

double Cal() {
	double temp1, temp2;
	node cur, temp;
	while (!q.empty()) {
		cur = q.front();
		q.pop();
		if (cur.flag == true) s.push(cur);
		else {
			temp2 = s.top().num;
			s.pop();
			temp1 = s.top().num;
			s.pop();
			temp.flag = true;
			if (cur.op == '+') temp.num = temp1 + temp2;
			else if (cur.op == '-') temp.num = temp1 - temp2;
			else if (cur.op == '*') temp.num = temp1 * temp2;
			else temp.num = temp1 / temp2;
			s.push(temp);
		}
	}
	return s.top().num;
}

int main() {
	op['+'] = op['-'] = 1;
	op['*'] = op['/'] = 2; //map
	while (getline(cin, str), str != "0") {
		for (string::iterator it = str.end() - 1; it !=str.begin(); it--) { //注意! -1
			if (*it == ' ') { str.erase(it); }
		}
		while (!s.empty()) s.pop(); // 清空栈
		Change();
		printf("%.2f\n", Cal());
	}

	return 0;
}

1032 Sharing (25 分)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being are stored as showed in Figure 1.

fig.jpg

Figure 1

You are supposed to find the starting position of the common suffix (e.g. the position of i in Figure 1).

Input Specification:

Each input file contains one test case. For each case, the first line contains two addresses of nodes and a positive N (≤10​5​​), where the two addresses are the addresses of the first nodes of the two words, and N is the total number of nodes. The address of a node is a 5-digit positive integer, and NULL is represented by −1.

Then N lines follow, each describes a node in the format:

Address Data Next

whereAddress is the position of the node, Data is the letter contained by this node which is an English letter chosen from { a-z, A-Z }, and Next is the position of the next node.

Output Specification:

For each case, simply output the 5-digit starting position of the common suffix. If the two words have no common suffix, output -1 instead.

Sample Input 1:

11111 22222 9
67890 i 00002
00010 a 12345
00003 g -1
12345 D 67890
00002 n 00003
22222 B 23456
11111 L 00001
23456 e 67890
00001 o 00010

Sample Output 1:

67890

Sample Input 2:

00001 00002 4
00001 a 10001
10001 s -1
00002 a 10002
10002 t -1

Sample Output 2:

-1

在最初的时候自己考虑,会不会出现相同节点的问题,最后发现多虑了,sharing point,共享节点,共用节点。

自己的思路是,使用struct存储data和next,然后search方法建两个vector,分别存储两个list的地址序列,最后逆序比较,当地址不同时跳出,输出最后一个相同的地址即可。

注意:char会读入空格,要先把空格的位置留出来。

出现了一个超时和一个错误,超时应该是vector太大了超出数组界限导致的,错误的原因还没找到。

#include<cstdio>
#include<vector>
using namespace std;

struct node {
	char data;
	//int pre;
	int next;
}Node[1000010];

int search(int head[]) {
	vector<int> list1, list2;
	int current[2];
	current[0] = head[0], current[1] = head[1];
	while ((Node[current[0]].next != -1) && (Node[current[1]].next != -1)) {
		list1.push_back(current[0]);
		list2.push_back(current[1]);
		current[0] = Node[current[0]].next;
		current[1] = Node[current[1]].next;
	}
	while(Node[current[0]].next != -1) {
		list1.push_back(current[0]);
		current[0] = Node[current[0]].next;
	}
	while (Node[current[1]].next != -1) {
		list2.push_back(current[1]);
		current[1] = Node[current[1]].next;
	}
	list1.push_back(current[0]);
	list2.push_back(current[1]);
	int start_pos = -1;
	vector<int>::iterator it1 = list1.end() - 1;
	vector<int>::iterator it2 = list2.end() - 1; //容易出错
	for (; it1 != list1.begin() && it2 != list2.begin(); it1--, it2--) {
		if (*it1 == *it2) {
			start_pos = *it1;
		}
		else {
			break; // jump out, if subfix ends
		}
	}
	return start_pos;


}


int main() {
	int head[2], N, tail[2];
	scanf("%d%d%d", & head[0], &head[1], &N);
	int j = 0;
	for (int i = 0; i < N; i++) {
		int tmp_addr;
		scanf("%d ", &tmp_addr);
		scanf("%c %d", &Node[tmp_addr].data, &Node[tmp_addr].next);
		if (Node[tmp_addr].next == -1){
			tail[j] = tmp_addr;
			j++;
		}
		else {
			//Node[Node[tmp_addr].next].pre = tmp_addr;
		}
	}
	int rst = search(head);
	if (rst != -1) {
		printf("%05d", rst);
	}
	else {
		printf("-1");
	}
	

	return 0;

}

 看了题解,发现自己想复杂了,其实不用每一个节点都check,题目默认的是找到开始节点就好了,只要找到公共开始节点,后面的节点都是共用。

怎么快速判断是否共用呢?最好的方法是加一个flag,然后对序列1在线处理,然后序列2逐个比较就可以了。

重构后的代码如下,可以全部通过

#include<cstdio>
#include<vector>
using namespace std;

const int maxn = 100010;

struct node {
	char data;
	int next;
	bool flag; //flag用来判断序列2中是否存在相同的数字
}Node[maxn];

int search(int head[]) {
	int ptr;
	for (ptr = head[0]; ptr != -1; ptr = Node[ptr].next)
		Node[ptr].flag = 1;
	for (ptr = head[1]; ptr != -1; ptr = Node[ptr].next)
	{
		if (Node[ptr].flag == 1)
			break;
	}

	return ptr;


}


int main() {
	for (int i = 0; i < maxn; i++) {
		Node[i].flag = 0;
	}
	int head[2], N;
	scanf("%d%d%d", & head[0], &head[1], &N);
	int j = 0;
	for (int i = 0; i < N; i++) {
		int tmp_addr;
		scanf("%d ", &tmp_addr);
		scanf("%c %d", &Node[tmp_addr].data, &Node[tmp_addr].next);
		
	}
	int rst = search(head);
	if (rst != -1) {
		printf("%05d", rst);
	}
	else {
		printf("%d", rst);
	}
	

	return 0;

}

 

 

1052 Linked List Sorting (25 分)

A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structures according to their key values in increasing order.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive N (<10​5​​) and an address of the head node, where N is the total number of nodes in memory and the address of a node is a 5-digit positive integer. NULL is represented by −1.

Then N lines follow, each describes a node in the format:

Address Key Next

where Address is the address of the node in memory, Key is an integer in [−10​5​​,10​5​​], and Next is the address of the next node. It is guaranteed that all the keys are distinct and there is no cycle in the linked list starting from the head node.

Output Specification:

For each test case, the output format is the same as that of the input, where N is the total number of nodes in the list and all the nodes must be sorted order.

Sample Input:

5 00001
11111 100 -1
00001 0 22222
33333 100000 11111
12345 -1 33333
22222 1000 12345

Sample Output:

5 12345
12345 -1 00001
00001 0 11111
11111 100 22222
22222 1000 33333
33333 100000 -1

从这道题中学到了很多点。

1.给出N个结点,但是不一定都有效,要从头结点开始,遍历一遍,判断哪个是有效结点。特判count = 0,在这个条件下,一个有效结点都没有,输入应该是"0 -1",输出"0 -1"。

2.虽然结点个数N是<105的,但是地址是一个5-digit number, maxn要到10W级别。

3.将数组排序的这个思想真的太神奇了!通过valid进行判断,将有效结点移动到前面!这样输出非常方便,但是注意要在struct里特别记录下结点地址,不然排序后会丢失。

4.注意输出addr的时候要用%05d补全,但是最后一个结点要输出-1.

 

#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 100010;

struct node {
	int addr, data, next;
	bool valid;
}Node[maxn];

bool cmp(node a, node b) {
	if (a.valid == 0 || b.valid == 0) {
		return a.valid > b.valid; //假如有无效的,后移
	}
	else {//假如两个数据都有效,按data从小到大排序
		return a.data < b.data;
	}

}

int main() {
	int N, start_addr;
	for (int i = 0; i < maxn; i++)
		Node[i].valid = false;
	scanf("%d%d", &N, &start_addr);


	for (int i = 0; i < N; i++) {
		int addr, data, next;
		scanf("%d%d%d", &addr, &data, &next);
		Node[addr].addr = addr;
		Node[addr].data = data;
		Node[addr].next = next;
		//Node[addr].valid = true;
	}
	int ptr = start_addr, count = 0;

	while (ptr != -1) {
		Node[ptr].valid = true;
		ptr = Node[ptr].next;
		count++;
	}

	if (count == 0) {
		printf("0 -1");
		return 0;
	}

	sort(Node, Node + maxn, cmp);

/*	for (int i = 0; i < N; i++)
	{
		if (i == N - 1)
		{
			Node[i].next = -1;
		}
		else {
			Node[i].next = Node[i + 1].addr;
		}
	}
*/
	printf("%d %05d\n", count, Node[0].addr); //注意这里是count不是N
	for (int i = 0; i < count; i++) {
		if (i != count - 1)
			printf("%05d %d %05d\n", Node[i].addr, Node[i].data, Node[i+1].addr);
		else
			printf("%05d %d -1\n", Node[i].addr, Node[i].data);
	}


	return 0;
}

 

 

pat甲级1138c语言_浙大PAT考试数据结构与算法模板整理 之前把PAT甲级题库刷完了,整理一下PAT的考点这次是完整版的了,加上了目录就不会迷路了目录字符串字符串类型转换KMP排序排名堆排序快速排序线性第K大归并排序判断插入排序二分整数二分链表单链表双链表栈和队列单调栈单调队列树反转二叉树构建二叉搜索树判断完全二叉树二叉树遍历重建二叉树AVL树插入判断红黑树DFS判断堆最低公共祖先并查集图最短路径与扩展问题判断哈密顿回路欧拉路径顶点覆盖最大团拓... 阅读详情

相关推荐

《算法笔记》栈、队列、链表、静态链表的应用(例题+代码C++)

一、栈的应用 1、栈的介绍 2、例题 二、队列的应用 1、队列的介绍 2、例题 三、链表的应用 1、链表的介绍 2、例题

编程小鹏的博客 383

PAT堆栈模拟队列

使用堆栈模拟队列,相当于当用两个桶装水: 一:为A 装水的时候 当左边的水桶满了,而右边的不为空的话,就可以说不能倒水了,输出Full 当左边的水桶没满,就可以倒到它满为止 当左边的水桶满了,右边的没有水,就把所有的水倒到右边去 二:倒水的时候 当右边的水桶满了之后就可以倒 如果是空的重新从左边装水 如果左边也没有水, 那么说明是空

瞭望的叶子的专栏 559

[AbutionGraph] 报表制作-使用Grafana动态可视化知识图谱指标

使用开源报表可视化工具Grafana实时监控时序知识图谱数据仓库AbutionGraph中的数据,实时性报表查询, 满足单次百万千万级的数据查询,毫秒级查询延迟,亚秒级对千亿数据量汇总统计,每日过亿报表查询/多维分析/日志分析等数据指标...

图特摩斯科技-博客 4279

数据结构刷题训练:用栈实现队列(力扣OJ)

栈和队列是数据结构中的两个重要概念,它们在算法和程序设计中都有着广泛的应用。本文将带你深入了解如何使用栈来模拟实现队列,让你在解决问题时更加灵活和创新,便于大家更深入的理解栈和队列。由于我们再模拟队列时需要用到两个栈,但调用函数时传两个栈又太麻烦,这里我们就使用结构体来定义两个栈(MyQueue),这样传参时就可以直接传结构体(MyQueue)指针就可以了。} MyQueue;使用栈模拟实现队列,让我们在实践中深入思考了数据结构的本质和应用,为我们的编程思维和算法设计能力提供了挑战和提升。t=N6B9。

2202_75605090的博客 2744

从高德、百度地图下载POI数据?用这个工具5分钟搞定GCJ02/BD09到WGS84的坐标纠偏

本文详细解析了高德、百度地图POI数据坐标偏移问题,并提供了从GCJ02/BD09到WGS84的高效转换方案。通过开源工具如coordtransform和ArcGIS等专业软件,实现毫米级精度的坐标纠偏,适用于商业选址、GIS分析等场景,显著提升数据准确性和工作效率。

weixin_26789847的博客 450

基于MediaPipe的智能俯卧撑计数与姿势矫正系统

在现代健身和体能训练中,俯卧撑是最基础也是最有效的自重训练动作之一。然而,许多人在进行俯卧撑训练时常常存在姿势不正确、计数不准确等问题。本文将介绍如何利用计算机视觉和姿态估计技术,开发一个智能的俯卧撑计数与姿势矫正系统。

qq_36224726的博客 916

用栈模拟实现队列

栈实现队列详解

weixin_74269833的博客 302

C#身份验证黑科技:用量子级加密与多维防御矩阵构建坚不可摧的用户管理系统!

某金融系统因身份验证漏洞导致200万用户数据泄露,量子级防御可将攻击面缩小99.99%。

墨夶的博客 353

栈与队列2——用栈实现队列

用栈实现队列

wtlll的博客 626

LOFIC / 全局快门在移动端的可行性:曝光容限、读出噪声与算力预算

手机端引入 LOFIC 与全局快门的核心权衡在于:在有限像素面积与功耗下,如何换取更高的动态范围与运动场景鲁棒性。LOFIC 通过侧向溢流到积分电容扩大满井并保持较高转换增益,全局快门在帧内一次性采样消除行时序伪影,但需付出像素填充率、读出噪声与片上存储功耗的代价。本文以工程可实操为目标,给出像素与读出链的简化模型、曝光损益测算、数据率与带宽估算、端到端算力与热预算方法,配套寄存器配置流程、帧内/帧间切换策略与验证清单,帮助在真实移动 SoC 与 ISP 约束下完成可行性评估与原型落地。

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1140

VIIRS-NPP夜间灯光遥感数据下载和预处理

右侧搜索框搜索“按掩膜提取”,提取出夜光影像中国区域。将其转换为Albers积投影和重采样到400m。点击右上角Export,选择shp格式。最后点export导出就行。点击复制按钮,来到这个。,ctrl + v粘贴。将小于0.3的值置为0。下载好月合成产品后,

热爱分享,热爱记录 1万+

【PAT】栈,队列,链表

一开始脑洞奇怪写了这个↓完全用链表的思想写的,很麻烦,得分22/25,最后两个一个段错误,一个超时。没有正确理解addr,addr可以是数组下标,所以正确方法应该是开一个100000>的数组。看了网上的还有这个简单的↓,使用reverse,虽然我感觉这已经不是链表的思想了。启发是有些链表的题用数组模式存储可以简化实现。这题好简单,开心一秒,畅想考试的时候遇到这么简单的(最看不懂题目的一集。完全抄的晴神的《上机训练》。到结点三就输入完毕了,后面的4 5 6是无效结点。这题也很简单,就是无效结点不讲武德= =

weixin_50952205的博客 487

项目介绍 MATLAB实现基于LSTM-XGBoost长短期记忆网络(LSTM)结合极端梯度提升(XGBoost)进行多变量时序预测的详细项目实例(含模型描述及部分示例代码)

本项目基于MATLAB平台,实现LSTM-XGBoost混合模型进行多变量时序预测。通过LSTM网络自动提取时序特征,结合XGBoost强大的回归能力,有效解决多变量时序数据的高维复杂性、长短期依赖捕捉等难题。项目包含完整的数据预处理流程、模型构建与训练方法,以及性能评估指标。提供的GUI界面支持参数调整、训练监控和结果可视化,适用于能源、金融、气象等多领域预测任务。配套代码详细注释,便于理解模型实现细节,为时序预测研究提供实用参考框架。

优质创作者: 人工智能技术领域 对于有一定基础的 MATLAB和Python带具体需求都可以详谈 MATLAB和Python可以提供代码调试服务加油 谢谢 你的鼓励是我前行的动力 谢谢支持 加油 谢谢 103

【2月3日PAT刷题笔记】——数据结构专题(1)队列,栈,链表

1032 Sharing (25分)(链表的遍历) 1052 Linked List Sorting (25分) (链表的排序与遍历) 1097 Deduplication on a Linked List (25分)(链表的遍历,map的使用) 1074 Reversing Linked List (25分)(链表的遍历) 1051 Pop Sequence (25...

爱写代码的坤坤的博客 293

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

PAT基本数据结构题总结_队列,栈,链表,二叉树,并查集等

PAT基本数据结构题_队列,栈,链表,二叉树,并查集等 leetcode与PAT的经典题目是互通的。 <–> 1. 1104. Sum of Number Segments 题目描述 https://pintia.cn/problem-sets/994805342720868352/problems/994805363914686464 结题思路 思路1:三个for循环,第一个for循环遍历索引,第二个for循环控制长度,第三个for循环累加固定长度的数组的和。 第一个for循环遍历0到n

qq_40092110的博客 476

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

PAT 第七章 栈、队列和链表

一 栈 二 队列 三 链表 1. 静态链表解题步骤 定义静态链表 struct node{ int address; int data; int next; int XXX; // 结点的某个性质 }; 程序开始前对链表初始化。一般来说需要对链表的XXX属性进行初始化,将其定义为正常情况达不到的数字。 for (int i = 0; i < maxn; i++) { Node[i].XXX = maxn; } 根据给出的首地址遍历得到整条链表。同时对

weixin_41945646的博客 156

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

PAT B 1025 反转链表(C语言)*栈和队列的应用

一、题目 给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转。例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 →2→1→6→5→4;如果 K 为 4,则输出应该为 4→3→2→1→5→6,即最后不到 K 个元素不反转。 输入格式: 每个输入包含 1 个测试用例。每个测试用例第 1 行给出第 1 个结点的地址、结点总个数正整数 N (≤10^​5​​ ...

Siumai's Blog 256

PAT《算法笔记》 提高篇(1)栈、队列、链表

栈 A1051 #include<cstdio> #include<vector> #include<stack> using namespace std; int main(){ int M,N,K,m,cnt; vector<int> v; scanf("%d%d%d",&M,&N,&K); for(int i=0;i<K;i++){ v.clear(); sta

1180610212的博客 203

第六课-数据结构(链表,栈,队列)

链表,栈,队列。以上都是基于数组进行模拟实现。当然我会补上链表实现,但是有一点需要去进行考虑,因为new,malloc操作都是动态去申请内存空间,所以当创建大量的节点的时候,时间上就是不太允许了。而且节点释放不放,就会造成内存泄漏 其实我上课一直,包括一些数据结构书籍都是使用的是结构体+指针,这里真的是很墙裂很强烈推荐使用数组去模拟实现,链表,栈,队列 链表题目 来源:AcWing,leetcode,pat AcWing 17. 从尾到头打印链表 AcWing 826. 单链表 Ac

weixin_44110100的博客 253

PAT 1025. 反转链表 (25)---最后一个测试点的坑点

题目描述: 给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转。例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4;如果K为4,则输出应该为4→3→2→1→5→6,即最后不到K个元素不反转。 输入格式: 每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(&lt;= 105)、以及正整数K(&lt;=N),即要求反转...

LITTENg的博客 2506

pat甲级什么水平_PAT甲级带我通关编程与数据结构新手村

写在前面半年前我努力啃下了《算法第4版》,作为非科班的学生,刚学完数据结构与算法,我同样也在思考如何巩固提高。最终我选择了适合自己的几个方式,PAT甲级正是其中之一。大概讲一下PAT甲级是啥。PAT(Programming Ability Test)是浙江大学组织的编程考试,分为乙级、甲级和顶级。浙大计算机学院和软件学院可用甲级、顶级成绩作为考研机试成绩,部分企业可为成绩优异者免除招聘笔试,具体情...

weixin_39781186的博客 3601

【PAT】PAT总结《搜索、打表、分治、排序算法、队列、栈、堆、Hash》

打表 打表这个技巧其实我们在素数部分的题已经涉及到了。还是要仔细思考,什么时候应该打表,打表有助于减少后续的计算的时候,我们应该打表, 特别是查询量特别大,即时计算无论多么快都会超时的情况。或者逆向运算比较快的时候,比如我们用开方求9的开方,和用3直接算出9是它的平方,从而3是9的开方,这两种速度差别非常大。在某些需要找平方因子的题里,可以先通过这种办法把平方因子预先计算然后存起来。 A1100 ...

elegant coder 3989

【汇总】PAT 备考

一、数据结构篇: 1.树及其相关算法 https://blog.youkuaiyun.com/Dirichlet_zju/article/details/84715654 2.图论算法 图论基础 https://blog.youkuaiyun.com/Dirichlet_zju/article/details/84546490 最短路径 https://blog.youkuaiyun.com/Dirichlet...

狄利克雷的博客 816

PAT 甲级 1074 Reversing Linked List (25 分)(链表部分逆置,结合使用双端队列和栈,其实使用vector更简单呐)

1074Reversing Linked List(25分) Given a constantKand a singly linked listL, you are supposed to reverse the links of everyKelements onL. For example, givenLbeing 1→2...

蔡军帅 395

算法笔记——七

第七章 7.1 栈的应用 栈没有元素时令TOP为-1 1.clear: TOP置为-1 2.size: 栈内元素的数为TOP+1 3.empty: 仅当TOP=-1时栈空,返回true 4.push: 先TOP加1,再把x存入TOP指向的位置 5.pop: 直接将栈顶指针TOP减1 6.top: st[TOP]即为栈顶元素 pop()和top()函数之前必须先试用empty()函数判断栈是否为空 ...

qq_41579514的博客 670
上一篇: PAT - 数学类总结
下一篇: PAT - DFS
DedicateToAI
博客等级 码龄9年 6粉丝 90原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值