Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

呵呵 代码不好 还是晒一次

Posted by kuailegirl at 2012-05-26 10:15:33 on Problem 1056
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator