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 |
哪位牛人帮忙给组BT的数据?#include <stdio.h> #include <string.h> bool judge(char *str,int start,int end) { int i,j,pos,px; char s[256]; bool flag=false; if(str[start]!='{'||str[end-1]!='}') return false; if(end-start==2||end-start==3) return true; pos=start+1; while(1) { if(pos>=end-1) break; if(str[pos]=='{') { for(i=pos+1;i<end-1;i++) { if(str[i]=='}') { if(i==end-2&&judge(str,pos,i+1)) return true; else if(i!=end-2&&str[i+1]==',') if(judge(str,pos,i+1)) { s[0]='{',px=1; for(j=i+2;j<end-1;j++) s[px++]=str[j]; s[px]='}'; s[px+1]='\0'; if(judge(s,0,strlen(s))) return true; } } } } flag=false; if(pos+1>=end-1) break; if(str[pos+1]!=',') return false; else flag=true; pos=pos+2; } if(flag) return false; return true; } int main() { int t,c=0; char str[256]; //freopen("d:\\1.txt","r",stdin); scanf("%d",&t); while(t--) { scanf("%s",str); printf("Word #%d: ",++c); judge(str,0,strlen(str))?printf("Set\n"):printf("No Set\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator