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<iostream> #include<string.h> using namespace std; struct Trinode { bool isend; Trinode *next[2]; Trinode() { isend=0; memset(next,0,sizeof(next)); } }; bool isable; void insert(char*s) { Trinode *temp=root; int i=0,nextpos; while(s[i]) { nextpos=s[i]-'0'; if(temp->next[nextpos]==0) { temp->next[nextpos]=new Trinode; temp=temp->next[nextpos]; } else { temp=temp->next[nextpos]; if(temp->isend) isable=0; } i++; } temp->isend=1; } int main() { char s[15]; Trinode *root=new Trinode; int i=0; while(cin>>s) { i++; isable=1; insert(s); while(cin>>s) { if(strcmp(s,"9")==0) break; if(!isable) continue; insert(s); } if(isable) cout<<"Set "<<i<<" is immediately decodable"<<endl; else cout<<"Set "<<i<<" is not immediately decodable"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator