| ||||||||||
| 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 <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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator