设为首页 加入收藏

TOP

hdu 1671 Phone List (字典树)
2015-07-20 17:43:27 来源: 作者: 【 】 浏览:211
Tags:hdu 1671 Phone List 字典
# include 
  
   
# include 
   
     # include 
    
      # include 
     
       # include 
       # define MAX 15 using namespace std; typedef struct Trie_Node { bool flag;//是否有子树 struct Trie_Node *next[MAX]; }Trie; void Insert(Trie *root,char *str) { Trie *p=root; int len=strlen(str); for(int i=0;i
       
        next[str[i]-'0']==NULL) { Trie *temp=(Trie*)malloc(sizeof(Trie)); for(int j=0;j
        
         next[j]=NULL; temp->flag=false; p->next[str[i]-'0']=temp; p->flag=true; } p=p->next[str[i]-'0']; } } bool find(Trie *root,char *str) { Trie *p=root; int len=strlen(str); for(int i=0;i
         
          next[str[i]-'0']==NULL) return false; p=p->next[str[i]-'0']; } return p->flag; } void del(Trie *root)//释放空间 { for(int i=0;i
          
           next[i]!=NULL) del(root->next[i]); } free(root); } int main() { int t,n,i; char str[10010][15]; while(~scanf("%d",&t)) { while(t--) { scanf("%d",&n); Trie *root=(Trie*)malloc(sizeof(Trie)); for(i=0;i
           
            next[i]=NULL; } root->flag=false; for(i=0;i
            
             
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDOJ 4445 Crazy Tank 下一篇7种排序 C++实现

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)