首页 > 代码库 > oj---九度oj---1153
oj---九度oj---1153
#include<cstdio> #include<stack> using namespace std; char str[110]; char res[110]; int main(){ while(scanf("%s",str)!=EOF){ stack<int> S; int i; for(i=0;str[i]!=0;i++){ if(str[i]==‘(‘){ S.push(i); res[i]=‘ ‘; } else if(str[i]==‘)‘){ if(!S.empty()){ S.pop(); res[i]=‘ ‘; } else{ res[i]=‘?‘; } } else res[i]=‘ ‘; } while(!S.empty()){ res[S.top()]=‘$‘; S.pop(); } res[i]=0; /*******/ puts(str); puts(res); } return 0; }
oj---九度oj---1153
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。