解题思路:
注意事项:
参考代码:
#include <stdio.h>
#define len sizeof (Stack)
typedef struct s{
char data[300];
int top;
}Stack;
void creat(){
char a[1000];
Stack *h;
h=(Stack *)malloc(len);
h->top=-1;
gets(a);
for (int i=0;a[i]!='\0';i++){
if (a[i]=='('){
h->top++;
h->data[h->top]=a[i];
}
if (a[i]==')'){
h->top--;
}
}
if (h->top==-1){
printf ("YES");
}else{
printf ("NO");
}
}
int main (){
creat();
}
0.0分
0 人评分