#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main()
{
string inPut;
stack<char> sinPut;
cout <<"input string, Ctrl+z to end" <<endl;
cin >>inPut;
string ::iterator iter = inPut.begin();
while(iter != inPut.end())
{
if(*iter != ')')
{
sinPut.push(*iter);
}
else
{
while(sinPut.top() != '(')
{
sinPut.pop();
if(sinPut.empty())
{
cout <<"wrong parameter input" <<endl;
goto Pause;
}
}
sinPut.pop();
sinPut.push('@');
}
++iter;
}
while(!sinPut.empty())
{
cout <<sinPut.top();
sinPut.pop();
}
cout <<endl;
Pause :system("pause");
return 0;
}
习题9.43
最新推荐文章于 2021-10-06 11:30:50 发布