|
|
вернуться в форумTO ADMINS Please check test#5, i think it wrong. expression contains successively two registers without the operator between them. thanks... but why this code get CRASH(INT_.....ZERO) ? #define S 32768 inline bool sc(char*a,char*b){ while(*a==*b)++a,++b; return *b==0; } ............ ............ char s[S],*j; {char a[S]; gets(a); char *i; for(i=a;*i;++i)if(*i>='a' && *i<='z')*i+='A'-'a'; for(i=a,j=s;*i;){ if(sc(i,"NOT"))*(j++)='!',i+=3; else if(sc(i,"AND"))*(j++)='&',i+=3; else if(sc(i,"OR"))*(j++)='|',i+=2; else if(sc(i,"TRUE"))*(j++)='1',i+=4; else if(sc(i,"FALSE"))*(j++)='0',i+=5; else if(*i>='A' && *i<='Z' || *i=='(' || *i==')') *(j++)=*(i++); else ++i; } *j='*'; #define IsReg(x) (x>='A' && x<='Z' || x=='0' || x=='1') for(i=s;*i!='*';++i) if(IsReg(i[0]) && IsReg(i[1])){ *i/=*i-*i; } } ............ ............ Edited by author 02.08.2006 15:47 sorry... bug would in my code... :( if the last word FALSE or TRUE, then this fucntion returun wrong result... inline bool sc(char*a,char*b){ while(*a==*b)++a,++b; return *b==0; } |
|
|