杭电ACM 2397 题,用字典树怎么写?高手给个AC代码!谢谢! 或者帮我看看,我错哪了?

题目地址
http://acm.hdu.edu.cn/showproblem.php?pid=2397

我的代码:

#include<iostream>
#include<string.h>
using namespace std;
char word[105];
char name[105];
struct tree
{
tree *next[26];
int c;
};

tree *newtree()
{
int i;
tree *s=new tree;
for(i=0;i<26;i++)
s->next[i]=NULL;
s->c=0;
return s;
}

void creat(tree *s,char *str)
{
int i;
tree *newnode;
if(*str==0)return;
for(i=0;str[i];i++)
if(islower(str[i]))
str[i]-=32;
for(i=0;str[i];i++)
{
if(!isupper(str[i]))
continue;
if(s->next[str[i]-'A']!=NULL)
{
s=s->next[str[i]-'A'];
}
else
{
newnode=newtree();
s->next[str[i]-'A']=newnode;
s=newnode;
}
}
s->c=1;
}

void search(tree *root,int t)
{

int i;

for(i=0;i<26;i++)
{
if(root->next[i])
{

word[t]=i+'A';
if(root->next[i]->c==1)
{
word[t+1]='\0';
printf("%s\n",word);
root->next[i]->c=0;
}
search(root->next[i],t+1);
}
}
}

int main()
{
int i,k,t=0;
int d=1;

tree *root=newtree();

while(scanf("%s",name)!=EOF)
{

if(strcmp(name,"EOD")&&strcmp(name,"EOT"))
{
t=1;
int a[30];
a[0]=0;
for(i=0,k=-1;name[i];i++)
{
if(name[i]=='-')
{
k=i+1;
a[t++]=k;
name[i]='\0';
}
}

for(i=0;i<t;i++)
creat(root,name+a[i]);
}
else
{

printf("WORDS IN DOCUMENT #%d\n",d++);

search(root,0);
if(strcmp(name,"EOT")==0)break;
}
}
return 0;
}

glo.onRollOver = function(){
loc1.gotoAndStop(1)
loc2.gotoAndStop(1)
loc3.gotoAndStop(1)
loc4.gotoAndStop(1)
loc5.gotoAndStop(1)
loc6.gotoAndStop(1)
loc7.gotoAndStop(1)
loc8.gotoAndStop(1)
loc9.gotoAndStop(1)
loc10.gotoAndStop(1)
loc11.gotoAndStop(1)
loc12.gotoAndStop(1)
loc13.gotoAndStop(1)
loc14.gotoAndStop(1)
loc15.gotoAndStop(1)
loc16.gotoAndStop(1)
loc17.gotoAndStop(1)
loc18.gotoAndStop(1)
loc19.gotoAndStop(1)
}

可简化为

glo.onRollOver = function(){
for(var i=1; i<=16; i++){
_root['loc'+i].gotoAndStop(1)
}
}

其它的差不多的
如果还没解决你的问题,可以加我百度HI账号。
温馨提示:内容为网友见解,仅供参考
无其他回答

Warning: Invalid argument supplied for foreach() in /www/wwwroot/aolonic.com/skin/templets/default/contents.html on line 45
相似回答
大家正在搜