示例#1
0
文件: h3.c 项目: psc0606/embedded
void main()
{
	int i, n;
	Node *a = NULL, *b = NULL;
	printf("input a:\n");
	for (i = 0; i < 5; i++)
	{
		scanf("%d",&n);
		a = insert_node(a,creat_node(n));
	}
	printf("input b:\n");
	for (i = 0; i < 3; i++)
	{
		scanf("%d",&n);
		b = insert_node(b,creat_node(n));
	}
	if (Sub_link(a,b))
	{
		printf("a包含b\n");
	}
	else
	{
		printf("a不包含b\n");
	}
	destroy(a);
	destroy(b);
}
示例#2
0
void main(int argc, char **argv)
{
    // assume head no meaning
    struct node* head = creat_node(0);
    struct node* a = creat_node(1);
    struct node* b = creat_node(2);
    struct node* c = creat_node(5);
    insert(head, a);
    insert(a, b);
    insert(b, c);
    print_list(head);
    head = reverse(head);
    print_list(head);
}
示例#3
0
文件: particia.c 项目: iamon3/C_DFS
void insert(patricia **root,char *word)
{
  patricia **temp;
  temp = (patricia**)malloc(sizeof(patricia*));
  (*temp)=(*root);
  int l=strlen(word), i=0, j=0, len=0;
  if(!root)
    {
      printf("Pointer TO Pointer Of Patricia Is NULL.\nSo Word Was Not Inserted\n");
      return;
    }
  if(!(*temp))
    {
      *root=creat_node(word);
      printf("Word Inserted Succesfully\n");
      return;
    }
  while(1)
    {
      len = strlen((*temp)->info);
      while( (*temp)->info[j] == word[i]  &&  j < len ) { i++; j++;}
      if(i == l)
	{
	  printf("Duplicate Key Tried To Insert\n");
	  return;
	}
      
      //i--;
      if( !((*temp)->next[j]) )
	{
	  (*temp)->next[j] = creat_node(word+i);
	  printf("Word Inserted Succesfully\n");
	  return;
	}
      (*temp) = (*temp)->next[j];
      j=0;
      
    }
  return;
}