似乎发现一个问题
  • 板块工单反馈版
  • 楼主FLUC
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/5/4 09:35
  • 上次更新2023/10/28 02:13:57
查看原帖
似乎发现一个问题
457870
FLUC楼主2022/5/4 09:35

P1155双栈排序的测试点#11卡了 但是数据一下,自己写了个程序测试

#include<iostream>
#include<stack>
using namespace std;
const int N=1e5+5;
int n, a[N];char ch;
int t;
stack<int>stk1, stk2;
int main() {
	freopen("P1155_11.in", "r", stdin);
	cin>>n;
	for(int i=1; i<=n; i++) {
		scanf("%d", a+i);
	}
	while(cin>>ch) {
		switch(ch) {
			case 'a':
				stk1.push(a[++t]);
				break;
			case 'b':
				if(!stk1.empty()) {
					printf("%d ", stk1.top());
					stk1.pop();
				}
				break;
			case 'c':
				stk2.push(a[++t]);
				break;
			case 'd':
				if(!stk2.empty()) {
					printf("%d ", stk1.top());
					stk1.pop();
				}
				break;
		}
	}
	return 0;
}

一输,好了,神奇的事情发生了 求助,是我程序有问题 还是那个点有问题

2022/5/4 09:35
加载中...