提交时间:2024-04-06 11:09:25

运行 ID: 141789

#include<bits/stdc++.h> using namespace std; int head=0,head1=0; char a[256]; char ch; void push(){ a[head++]=ch; } void pop1(){ head--; } void pop2(){ head=0; } bool empty(){ return head==0; } int main(){ //freopen("editor.in","r",stdin); //freopen("editor.out","w",stdout); while(cin>>ch){ if(ch!='#'&&ch!='@'){ push(); } else if(ch=='#'){ if(!empty()){ pop1(); } } else if(ch=='@'){ if(!empty()){ pop2(); } } } while(!empty()){ cout<<a[head1++]; head--; } }