标签:
#include<stdio.h> char curr; char LL1[1000]; int N=0; void scaner(); int digital(){ if(curr >= ‘0‘ && curr <= ‘9‘) { return 1; } else { return 0; } } int english(){ if(curr >= ‘a‘ && curr<=‘z‘ || curr >= ‘A‘ && curr <= ‘Z‘) { return 1; } else return 0; } int yuansuanf(){ if(curr==‘+‘||curr==‘-‘||curr==‘*‘||curr==‘/‘) { return 1; } else{ return 0; } } int end(){ if(curr!=‘#‘){ return 1; } else return 0; } int check(){ if(digital()==1){ scaner(); if(end()==1){ if(yuansuanf()==1){ return 1; } else if(yuansuanf()==0){ return 0; } } else if(end()==0){ return 1; } } return 0; } void checking(){ int number; qq: scaner(); if(digital()==1){ while(curr!=‘#‘){ number=check(); if(number==1){ goto qq; } else if(number==0){ break; } } } if(number==1){ printf("无错误\n"); } else printf("%c错误\n",curr); } void main() { char ch; int i=0; printf("请输入语法:(以#结束)\n"); do{ scanf("%c",&ch); LL1[i] = ch; i++; }while(ch != ‘#‘); scaner(); checking(); } void scaner(){ N++; if(LL1[N] == ‘ ‘){ N++; }else { curr = LL1[N]; } }
标签:
原文地址:http://www.cnblogs.com/caishun/p/5089567.html