#include<stdio.h>
#include<string.h>int i,t=1;char a[100];void E();
void E1();void T();void T1();void F(); void E(){ T();E1();}void T(){ F();T1();}void E1(){ if(a[i]=='+'||a[i]=='-'){ i++;T();E1();}else if(a[i]=='#'||a[i]==')'){ i++;}}void T1(){ if(a[i]=='*'||a[i]=='/'){ i++;F();T1();}else if(a[i]=='#'||a[i]==')'){ i++;}}
void F(){ int d;if((a[i]<='z'&&a[i]>='a')||(a[i]<='Z'&&a[i]>='A')){ if((a[i++]<='z'&&a[i++]>='a')||(a[i++]<='Z'&&a[i++]>='A'))i++;else { printf("\n分析失败!\n");t=0;}}if(a[i]<='9'&&a[i]>='0'){ if(a[i++]<='9'&&a[i++]>='0')i++;else { printf("\n分析失败!\n");t=0;}}else if(a[i]=='('){ E();if(a[i]==')'){ i++;}else{ printf("\n分析失败!\n");exit (0);}}else{ printf("\n分析失败!\n");exit (0);}}int main(){ int len,d;start:printf("请输入表达式:\n");scanf("%s",a);len=strlen(a);a[len]='#';a[len+1]='\0';E();if(t==1){ printf("是正确的表达式\n");}printf("是否重试?重试输入1:");scanf("%d",&d);if(d=1)goto start;return 0;