. - - 3


T:T/F","T:F","F:i","F:c","F:(E)",NULL };

char TS[]= "+-*/()ic#" ;

char NTS[]= "+-*/()ic#FTEZ" ;

char s[100]; int ns;

char m[100]; int sp;

 

: 0 - , 1-, 2-, 3- .

 

int TBL[14][10]={

/* + - * / ( ) i c # err */

/* + */ { 0,0,0,0,1,0,1,1,0,0 },

/* - */ { 0,0,0,0,1,0,1,1,0,0 },

/* * */ { 0,0,0,0,1,0,1,1,0,0 },

/* / */ { 0,0,0,0,1,0,1,1,0,0 },

/* ( */ { 0,0,0,0,1,0,1,1,0,0 },

/* ) */ { 2,2,2,2,0,2,0,0,2,0 },

/* i */ { 2,2,2,2,0,2,0,0,2,0 },

/* c */ { 2,2,2,2,0,2,0,0,2,0 },

/* # */ { 0,0,0,0,1,0,1,1,0,0 },

/* F */ { 2,2,2,2,0,2,0,0,2,0 },

/* T */ { 2,2,1,1,0,2,0,0,2,0 },

/* E */ { 1,1,0,0,0,1,0,0,2,0 },

/* Z */ { 0,0,0,0,0,0,0,0,3,0 },

/*err*/ { 0,0,0,0,0,0,0,0,0,0 },

};

STS

 

int STS(char c,char T[]) {. . .}

 

main . , .

 

void main()

{ int i,j,stop;

printf(":"); gets(s); strcat(s,"#");

ns=0; sp=0; m[0]='#'; m[1]='\0';

nts=strlen(TS); stop=0;

while(!stop)

{ i=TBL[ STS(m[sp],NTS) ][ STS(s[ns],TS) ];

switch (i) {

case 1: sp++; m[sp]=s[ns]; m[sp+1]='\0';

ns++; break; //

case 2: if (TESTGR()==0) //

stop++; break;

case 3: stop++; break;

default: stop++; break;

}}}

TESTGR : , , .