#include
#include
#include
#include
using namespace std;
int main(int argc, char argv[])
{
ifstream cin("F:\\test.txt");
string s;
char ss[100];
stack
temp; while (cin.getline(ss, 100)) { s = ss; cout << ss << endl; int length = s.size(); for (int i = 0; i < length; i++) { //如果是{,[,(则进行入栈操作 if (s[i] == '{') temp.push(s[i]); else if (s[i] == '[') temp.push(s[i]); else if (s[i] == '(') temp.push('('); //如果是},],)则进行出栈操作 else if (s[i] == '}') { if (temp.top() == '{') { cout << temp.top() <
假设表达式中允许包括3中括号:(,[,{,设计一个算法采用顺序栈判断表达式中的括号是否正确配对
最新推荐文章于 2022-11-01 21:27:10 发布