DianNier  
点击查看代码
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	string m;cin>>m;cin.ignore();
	for(int i=0;i<m.size();i++)
	{
		if(m[i]=='(') s.push(i);
		else
		{
			if(s.empty()) 
			{
				cout<<"error"<<'\n';
				return 0;
			}
			else
			{
				cout<<s.top()<<" "<<i<<'\n';
				s.pop();
			 } 
		}
	}
	return 0;
}
posted on 2024-02-29 09:43  芭娜娜banana  阅读(17)  评论(0)    收藏  举报