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 |
呵呵 代码不好 还是晒一次#include<iostream> #include<string.h> #include<memory.h> using namespace std; int code[2000]; char temp[200]; int main() { int c=0; int flag=0; while(cin>>temp) { if(strcmp(temp,"9")==0 ) { memset(code,0,sizeof(code)); c++; if(flag==0) cout<<"Set "<<c<<" is immediately decodable"<<endl; else cout<<"Set "<<c<<" is not immediately decodable"<<endl; flag=0; continue; } int i; int root=1; for(i=0;i<strlen(temp);i++) { if(code[root]=='S') flag=1; if(temp[i]=='0') root=root*2; else root=root*2+1; if(i==strlen(temp)-1) code[root]='S'; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator