该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
//函数:检查输入是否合法void Health(char in[]){int k;int i;int a=0,b=0;//health1if(strlen(in)>60) {printf("ERROR!!!输入长度请勿超过60\n");// 队长错误判断在这!!!exit(0);}//health2for(i=0;in[i]!='\0';i++){if(in[i]=='+'||in[i]=='-'||in[i]=='*'||in[i]=='/'||in[i]=='^'||in[i]=='.'||in[i]=='('||in[i]==')'||in[i]=='='||in[i]=='s'||in[i]=='c'||in[i]=='t'||in[i]=='S'||in[i]=='C'||in[i]=='T'||in[i]=='l'||in[i]=='L'||in[i]>=48&&in[i]<=57);else{printf("ERROR!!有不存在的符号");// 队长错误判断在这!!!exit(0);}if(in[i+1]=='\0')if(in[i]>=48&&in[i]<=57){printf("ERROR!!结尾请输入等号\n");// 队长错误判断在这!!!exit (0);}}//health3for(i=0;in[i]!='\0';i++){//3.1if(in[i]=='+'||in[i]=='-'||in[i]=='*'||in[i]=='/'||in[i]=='^'){if(in[i]=='+'||in[i]=='*'||in[i]=='/'||in[i]=='^'){if(in[i-1]>=48&&in[i-1]<=57||in[i-1]==')');else{printf("ERO1!!运算符左不可带左括号\n");// 队长错误判断在这!!!exit(0);}}if(in[i+1]>=48&&in[i+1]<=57||in[i+1]=='('||in[i+1]=='s'||in[i+1]=='c'||in[i+1]=='t'||in[i+1]=='S'||in[i+1]=='C'||in[i+1]=='T'||in[i+1]=='l'||in[i+1]=='L');else{printf("REO2!!运算符右不可带右括号\n");// 队长错误判断在这!!!exit(0);}}//h3.1.2if(in[i]=='('){if(in[i+1]=='-'){for(k=1;in[i+1+k]!='\0';k++){if(in[i+1+k]>=48&&in[i+1+k]<=57||in[i+1+k]=='.'||in[i+1+k]==')'){//printf("haha,%c\n",in[i+1+k]);if(in[i+1+k]==')'){break;}}else{printf("REO_k!!负数请单独用括号括起\n");// 队长错误判断在这!!!exit(0);}}}}//h3.2if(in[i]==')'){a++;if(in[i+1]>=48&&in[i+1]<=57){printf("ERO4!!左括号前不能带数字\n");// 队长错误判断在这!!!exit(0);}}if(in[i]=='('){b++;if(in[i-1]>=48&&in[i-1]<=57){printf("ERO3!!右括号后不能带数字\n");// 队长错误判断在这!!!exit(0);}}//h3.3if(in[i]=='s'||in[i]=='c'||in[i]=='t'||in[i]=='S'||in[i]=='C'||in[i]=='T'||in[i]=='l'||in[i]=='L'){if(in[i+1]!='('){printf("ERO_sct_k!!三角函数、对数运算符后请带左括号\n");// 队长错误判断在这!!!exit(0);}if(in[i-1]>=48&&in[i-1]<=57||in[i-1]==')'){printf("ERO_sct_s!!三角函数、对数运算运算符前勿带右括号及数字\n");// 队长错误判断在这!!!exit(0);}}}//h3.2-1if(a!=b){printf("ERO5!!左右括号数量不等\n");// 队长错误判断在这!!!exit(0);}}