您的位置:首页 > 其它

sdut 1479行编译器!!

2014-02-24 20:13 369 查看
点击打开链接

#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
stack<char>s;
int main()
{
char ch[1000],sh[1000];
while(scanf("%s",sh)!=EOF)
{
int len=strlen(sh);
for(int i=0;i<len;i++)
{
if(sh[i]!='#'&&sh[i]!='@')
{
s.push(sh[i]);
}
else if(sh[i]=='#'&&!s.empty())
s.pop();
else if(sh[i]=='@')
{
while(!s.empty())
{
s.pop();
}
}
}
int j=0;
while(!s.empty())
{
ch[j++]=s.top();//出栈时的字符顺序是反的,要另存
s.pop();
}
ch[j]='\0';//数组的结束标志
for(int i=j-1;i>=0;i--)
printf("%c",ch[i]);
printf("\n");
}
return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: