oj---九度oj---1153
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章