UVa11988

来源:互联网 发布:杭州网络推广公司排名 编辑:程序博客网 时间:2024/06/17 02:16
/*
关键是理解home和end的作用,home是在最前面插入字符,end是在最后输入字符。
因此设置两个string,beg和end分别是在前面插入字符串和在最后插入字符串
home表示在在最前面插入还是在最后插入。
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<string.h>
#include<math.h>
#include<queue>
#include<stack>
#include<unordered_map>
using namespace  std;
const int maxn=100000+5;
char s[maxn];
int main(){
    while(scanf("%s",s)!=EOF){
        bool home=false;
        int n=strlen(s);
        string beg,end;
        for(int i=0;i<n;++i){
            if(isalpha(s[i])||s[i]=='_'){
                if(home)beg.push_back(s[i]);
                else end.push_back(s[i]);
            }else{
                end=beg+end;
                beg.clear();
                home=(s[i]=='[');
            }
        }
        cout<<beg+end<<endl;
    }
    return 0;
}