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 |
求指教:老是WA#include <stdio.h> #include <string.h> #include <iostream> using namespace std; struct code{ char seq[11]; int len;}; int main() { int i,j,count,min,flag,n; code ary[8]; n=0; //while( ( scanf("%s",ary[0].seq) )!=EOF ) while(cin>>ary[0].seq) { ary[0].len=strlen(ary[0].seq); flag=1; n++; count=0; do{ count++; scanf("%s",ary[count].seq); ary[count].len=strlen(ary[count].seq); }while(ary[count].seq[0]!='9'); for(i=0;i<count-1 && flag!=0;i++) for(j=i+1;j<count && flag!=0;j++) { if(ary[i].len<=ary[j].len) min=ary[i].len; else min=ary[j].len; flag=strncmp(ary[i].seq,ary[j].seq,min); } if(flag==0) printf("Set %d is not immediately decodable\n",n); else printf("Set %d is immediately decodable\n",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