#include<string.h>
#include <stdio.h>
int judge(char a,char b)
{
char left[4]={'{','[','(','<'},right[4]={'}',']',')','>'};
int i;
for(i=0;i<4;i++)
if(a==left[i])
if(b==right[i])
return(1);
return(0);
}
int value(char a)
{
switch(a)
{
case '{':
return 1;
case '[':
return 2;
case '(':
return 3;
case '<':
return 4;
case '>':
return 5;
case ')':
return 6;
case ']':
return 7;
case '}':
return 8;
default :
return 0;
}
}
main()
{
char bracket[20];
int i,j;
scanf("%s",bracket);
if(strlen(bracket)%2==0)
for(i=0;i<strlen(bracket);)
{
if(judge(bracket[i],bracket[i+1]))
{
if(i && value(bracket[i-1])>=value(bracket[i])) //若{{ }}这样可以,将=运算
{
printf("there is some wrong with the program\n");
i=100;
break;
}
for(j=i;j<strlen(bracket);j++)
if(j<strlen(bracket)-2)
bracket[j]=bracket[j+2];
else
{ bracket[j]='\0';
bracket[j+1]='\0';
}
if(i) i--;
}
else
i++;
}
else
{ printf("there is some wrong with the program\n");
i=100;
}
if(strlen(bracket)==0)
printf("there is no wrong with the program\n");
else
if(i!=100)
printf("there is some wrong with the program\n");
}
雁无留踪之意,水无取影之心