*p=s; while(p-s<len){ if(*p=='<'){ if(!s1.empty()){ s2.push(s1.top()); s1.pop(); } } else if(*p=='>'){ if(!s2.empty()){ s1.push(s2.top()); s2.pop(); } } else if(*p=='-'){ if(!s1.empty()){ s1.pop(); } } else { s1.push(*p); } p++; } while(!s1.empty()){ s2.push(s1.top()); s1.pop(); } string ans; while(!s2.empty()){ ans+=s2.top(); s2.pop(); } reverse(ans.begin(), ans.end()); cout<<ans<<endl; /* end */ return 0; } [2024-10-25 17:28:04 | AI写代码神器 | 518点数解答]