rendered paste body#include <iostream>#include <string>#include <stack>using namespace std;int main(){ char str[] ="{ @111000; < qwe > ![<{asd! }"; cout<<"code: "<<str<<endl<<endl; stack<char> tags; char tgOpen[] = "[<{"; char tgClose[] = "]>}"; char *ch; bool comment = false; for (int i=0; i<strlen(str); i++) { if (str[i]=='!') comment=!comment; if (!comment) { if ((ch = strchr(tgOpen, str[i]))!=NULL) { cout<<*ch<<endl; tags.push(*ch); } if ((ch = strchr(tgClose, str[i]))!=NULL) { cout<<*ch<<endl; if (!tags.empty()) { if (tgOpen[ch-tgClose] != tags.top()) cout<<"tags error 1!"<<endl; tags.pop(); } else { cout<<"tags error 2!"<<endl; } } } } if (!tags.empty()) { cout<<"tags error 3!"<<endl; } cout<<"comment: "<<comment<<endl; /*char* c = str; while (*c) { if (ch = *strchr(tgOpen, (char)*c)) { cout << ch << endl; } c++; }*/ return 0;}