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 |
Re:AC了的DFA做法呵呵。。。。In Reply To:AC了的DFA做法呵呵。。。。 Posted by:hanjialong at 2008-09-09 19:19:27 > #include<iostream> > #include<ctype.h> > using namespace std; > > const int error=9; > > int f(int s,char input) > { > switch(s) > { > case 0: > { > if(isdigit(input)) return 2; > if(input=='+'||input=='-') return 1; > if(input=='\0') return 8; > break; > } > case 1: > { > if(isdigit(input)) return 2; > break; > } > case 2: > { > if(isdigit(input)) return 2; > if(input=='.') return 3; > if(input=='e'||input=='E') return 5; > if(input=='\0') return 8; > break; > } > case 3: > { > if(isdigit(input)) return 4; > break; > } > case 4: > { > if(isdigit(input)) return 4; > if(input=='e'||input=='E') return 5; > if(input=='\0') return 8; > break; > } > case 5: > { > if(isdigit(input)) return 7; > if(input=='+'||input=='-') return 6; > break; > } > case 6: > { > if(isdigit(input)) return 7; > break; > } > case 7: > { > if(isdigit(input)) return 7; > if(input=='\0') return 8; > break; > } > } > return error; > } > char *p; > > char get() > { > p++; > return *(p-1); > } > > int main() > { > const int maxn=1100; > char a[maxn]; > int s,t; > scanf("%d\n",&t); > while(t--) > { > cin.getline(a,maxn); > for(p=a;*p;p++); > for(;p>=a&&*(p-1)==' ';p--); > *p='\0'; > for(p=a;*p==' ';p++); > s=0; > while((s=f(s,get()))!=8&&s!=error); > if(s==8) printf("LEGAL\n"); > else printf("ILLEGAL\n"); > } > return 0; > } 我的DFA怎么就WA呢 T_T Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator