UVa644 - Immediate Decodability
#include <cstdio> #include <cstring> int main() { char s[100][100]; char str[100]; int cas=1; int n; int i,j,k; while(scanf("%s",str)!=EOF) { n=0; while (str[0]!='9') { strcpy(s[n++],str); scanf("%s",str); } int flag=1; for(i=0;i<n-1;++i) { for(j=i+1;j<n;++j) { int len=strlen(s[i])<strlen(s[j])?strlen(s[i]):strlen(s[j]); for(k=0;k<len&&s[i][k]==s[j][k];++k); if(k==len) { flag=0; goto loop; } } } loop: if(flag==1) printf("Set %d is immediately decodable\n",cas++); else printf("Set %d is not immediately decodable\n",cas++); } return 0; }
补充:软件开发 , C++ ,