| ||||||||||
| 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 | |||||||||
唉????我没排序咋过的?????数据水的一匹In Reply To:注意排序。 Posted by:sunl449554866 at 2014-08-28 22:03:20 #include<iostream>
#include<cstdio>
using namespace std;
struct node
{
int num;
node *son[2];
node()
{
num=-1;
son[0]=NULL;
son[1]=NULL;
}
};
int flag=1;
void Insert(node *&p,char temp[],int i)
{
if(temp[i]=='\0')
{
if(p==NULL)
p=new node;
p->num=1;
}
else
{
if(p==NULL)
p=new node;
int tc=temp[i]-'0';
if(p->num==1)
flag=0;
else
Insert(p->son[tc],temp,i+1);
}
}
int main()
{
char temp[20];
node *root;
root=NULL;
int ctor=1;
while(~scanf("%s",temp))
{
if(temp[0]=='9')
{
if(flag)
printf("Set %d is immediately decodable\n",ctor++);
else
printf("Set %d is not immediately decodable\n",ctor++);
flag=1;
root=NULL;
}
else
{
if(flag)
Insert(root,temp,0);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator