标签:
#include<iostream> #include<stack> using namespace std; int main() { int ncase,num; char str; cin>>ncase; while(ncase--) { cin>>num; stack<char> st; for(int i=0;i<num;i++) { cin>>str; if(!st.empty()&&st.top()=='>'&&str=='<') { st.pop(); continue; } else st.push(str); } if(st.empty()) cout<<"legal\n"<<endl; else cout<<"illegal\n"<<endl; } return 0; }
标签:
原文地址:http://blog.csdn.net/chaoyueziji123/article/details/44153209