AC

♻️lzhh_lzhh32  •  2个月前


#include<bits/stdc++.h>
using namespace std;
stack<int> s1;
stack<int> s2;
int main(){
	int n,m,maxl,p,a,b;		//s1进栈数 s2进栈数 
	cin>>maxl>>n>>m;
	while(n--){
		cin>>p;
		s1.push(p);
	}
	while(m--){
		cin>>p;
		s2.push(p);
	}
	cin>>a>>b;
	if(a!=0){
		while(a--){
			cout<<s1.top()<<' ';
			s1.pop();
		} 
	}else cout<<"no";
	cout<<endl;
	if(b!=0){
		while(b--){
			cout<<s2.top()<<' ';
			s2.pop();
		} 
	}else cout<<"no";
	cout<<endl;
	if(!s1.empty()){
		while(!s1.empty()){
	 		cout<<s1.top()<<' ';
		 	 s1.pop(); 
		}
	}else cout<<"no";
	cout<<endl;
	if(!s2.empty()){
		while(!s2.empty()){
	 		cout<<s2.top()<<' ';
		 	s2.pop(); 
		}
	}else cout<<"no";
	return 0;
} 

评论:

请先登录,才能进行评论