Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大侠看看啊,哪里错了啊?#include "stdio.h" #define MAX 1000 char p[MAX],t[MAX],r,l,c; int pi,ti,cou; void insert(void){ if (t[--ti]=='!'){ l=p[--pi]; p[pi++]=((l=='F')?'V':'F'); } else { r=p[--pi]; l=p[--pi]; if (t[ti]=='|') p[pi++]=(r=='F' && l=='F')?'F':'V'; else p[pi++]=(r=='V' && l=='V')?'V':'F'; } } int main(){ for (c=getchar(),cou=1;c!=EOF;c=getchar(),cou++){ for (ti=0,pi=0;c!='\n';c=getchar()){ switch (c){ case ' ': continue; case 'F': case 'V': p[pi++]=c; continue; case '(': t[ti++]=c; continue; case '!': if (ti==0 || t[ti-1]!='!') t[ti++]=c; else ti--; continue; case ')': while(t[ti-1]!='(') insert(); ti--; continue; case '|': case '&': if (ti==0){ t[ti++]=c; continue; } if (t[ti-1]!='(' && c>t[ti-1]){ insert(); t[ti++]=c; } else t[ti++]=c; continue; } } while(ti>0) insert(); printf("Expression %d: %c\n",cou,p[0]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator