Small code to Master learning Motoki

Source: Internet
Author: User

 /*****************  run   Environment:http://www.anycodes.cn/zh/  content:  cardinality tree   ************* /  #include  <stdio.h> #include  <stdlib.h>typedef struct radixnode  {    char *str;     struct radixnode *lchild ,  *rchild; } radixnode;void radix_insert (RADIXNODE&NBSP;*NODE,&NBSP;CHAR&NBSP;*STR) {      int i;     for  (i = 0; str[i] ! =  ' + ';  i++)  {                          if  (str[i] ==  ' 0 ')  {               if  ( Node->lchild == null)                      node->lchild = (radixnode*)  calloc (sizeof (Radixnode),  1);                node = node->lchild;                           }            else {               if  ( Node->rchild == null)                      node->rchild =  (radixnode*) calloc (sizeof ( Radixnode),  1);                node =  node->rchild;          }                     }      node->str = str;} Void radix_preorder_walk (Radixnode *node) {     if  (node !=  NULL)  {          if  (node->str !=  NULL)                printf ("%s\n", &NBSP;NODE-&GT;STR);           radix_preorder_walk (node-> Lchild);           radix_preorder_walk (Node->rchild);      }}int main (void) {     radixnode *root =   (radixnode*) malloc (sizeof (Radixnode)),      char ss[5][5]={"01", "011", "101" , "1010", "1011"};     radix_insert (Root, ss[0]);      radix_insert (Root, ss[1]);       radix_insert (root, ss[2]);       radix_insert (Root, ss[3]);       radix_ Insert (root, ss[4]);       radix_preorder_walk (Root);      return 1;}

Original http://blog.csdn.net/dc_726/article/details/7391988

Modification eliminates errors caused by warnings and certain compilers



Small code to Master learning Motoki

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.