a

许熠谦de小号~~~  •  6个月前


include<bits/stdc++.h>

using namespace std; typedef struct Stack{

int a[100002];
int top1,top2; 

}LS; void init(LS &S){

S.top1=0;
S.top2=100001;

} void push1(LS &S,int n){

int x;
for(int i=1;i<=n;i++){
	cin>>x;
	S.top1++;
	S.a[S.top1]=x;
}

} void push2(LS &S,int m){

int x;
for(int i=1;i<=m;i++){
	cin>>x;
	S.top2--;
	S.a[S.top2]=x;
}

} void pop1(LS &S,int n2,int m2){

if(n2==0){
	cout<<"no";
}else {
	for(int i=1;i<=n2;i++){
		cout<<S.a[S.top1]<<" ";
		S.top1--;
	}
}
cout<<"\n";
if(m2==0){
	cout<<"no";
}else{
	for(int i=1;i<=m2;i++){
		cout<<S.a[S.top2]<<" ";
		S.top2++;
	}
}
cout<<"\n";

} void pop2(LS &S){

if(S.top1==0){
	cout<<"no";
}else{
	while(S.top1>0){
		cout<<S.a[S.top1]<<" ";
		S.top1--;
	}
}
cout<<"\n";
if(S.top2==100001){
	cout<<"no";
}else{
	while(S.top2<100001){
		cout<<S.a[S.top2]<<" ";
		S.top2++;
	}
}

} int main(){

int ms,n,m,n2,m2;
Stack a;
init(a);
cin>>ms>>n>>m;
push1(a,n);
push2(a,m);
cin>>n2>>m2; 
pop1(a,n2,m2);
pop2(a);

}


评论:

请先登录,才能进行评论