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

前缀编码问题,二叉树很简单呀!定义错了一个变量,wa了好几次

Posted by abcd1236386 at 2012-06-21 16:14:54 on Problem 1056
#include <iostream>
#include <math.h>
#include <string.h>
#include <stdio.h>
using namespace std;
char buf[11];
bool has[2048];
int mx(int a,int b,int c)
{
	a=a>b?a:b;
	a=a>c?a:c;
	return a;
}
int mx(int a,int b)
{
	return a>b?a:b;
}
int main()
{
	memset(has,false,sizeof(has));
	bool iside=true;
	int set=0;
	while(cin>>buf)
	{
		if(buf[0]=='9')
		{
			set++;
			memset(has,false,sizeof(has));
			if(iside)
				cout<<"Set "<<set<<" is immediately decodable\n";
			else
				cout<<"Set "<<set<<" is not immediately decodable\n";
		  iside=true;

		}
		else
		{
			if(!iside)
				continue;
			int cid=1;
			for (int i=0;buf[i]!=0;i++)
			{
				if(buf[i]=='0')
					cid<<=1;
				else
				{
					cid<<=1;
					cid+=1;
				}
				if(has[cid])
					iside=false;

			}
			has[cid]=true;
		}
	}

	
	
}

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