
1 #include<stdio.h> 2 typedef struct{ 3 char array[50]; 4 int top,rear; 5 }DoubleStack; 6 void Create(DoubleStack*S) 7 { 8 char e; 9 S->top=0,S->rear=-1; 10 e=getchar(); 11 while(e!='@') 12 { 13 S->array[++S->rear]=e; 14 e=getchar(); 15 } 16 } 17 18 char Pop(DoubleStack*S,int i) 19 { 20 char e; 21 if(i==0)e=S->array[S->top++]; 22 else if(i==1)e=S->array[S->rear--]; 23 return e; 24 } 25 int Judge(DoubleStack*S) 26 { 27 char a,b; 28 DoubleStack*T=S; 29 while(S->top!=S->rear) 30 { 31 a=Pop(T,0); 32 b=Pop(T,1); 33 if(a!=b)return 0; 34 if(a=='&')return 0; 35 } 36 if(S->array[S->top]!='&')return 0; 37 return 1; 38 } 39 int main() 40 { 41 DoubleStack S; 42 Create(&S); 43 if(Judge(&S)) 44 printf("yes"); 45 else printf("no"); 46 return 0; 47 }