到这个时间,虽然不是很晚,但是挺累的,白天是在实训,晚上要去准备考研!回来的时候把这个题目给写了,现在得赶紧去睡觉了,明天还要早起打卡,唉!
算法的具体思想明天在实验室的时候找个时间来写!
[cpp]
#include
#include
using namespace std;
#define MAX 100 //整个的括号的长度不会超过50
/*284K 0MS*/
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i
char str[MAX];
int count=0;
int index=0;
for(int i=0;i
int j;
for(j=count;j str[index++]='(';
str[index++]=')';
count=a[i];
}
str[index]='\0';
int *b=new int[n];
int p=0;
//堆栈操作
stack
for(int i=0;i
if(str[i]=='(')
store.push('(');
else
{
int num=0;
while(store.top()!='(')
{
num++;
store.pop();
}
num++;
b[p++]=num;
store.pop();
for(int k=0;k
}
}
for(int i=0;i
delete []a;
}
system("pause");
return 0;
}
#include
#include
using namespace std;
#define MAX 100 //整个的括号的长度不会超过50
/*284K 0MS*/
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i
char str[MAX];
int count=0;
int index=0;
for(int i=0;i
int j;
for(j=count;j str[index++]='(';
str[index++]=')';
count=a[i];
}
str[index]='\0';
int *b=new int[n];
int p=0;
//堆栈操作
stack
for(int i=0;i
if(str[i]=='(')
store.push('(');
else
{
int num=0;
while(store.top()!='(')
{
num++;
store.pop();
}
num++;
b[p++]=num;
store.pop();
for(int k=0;k
}
}
for(int i=0;i
delete []a;
}
system("pause");
return 0;
}