void place(NODEPTR *plist, int x)
{
	NODEPTR  p, q = NULL;
	for (p = *plist; p != NULL; p = p->next)
		q = p;

	/* at this point, a node containing x must be inserted */

	insafter(q, x);
}
Beispiel #2
0
/* Drier program to test above function*/
int main()
{
	/* Start with the empty list */
	struct node* head = NULL;
	int ele;
	printf("Enter the element\n");
	while(scanf("%d",&ele)!=EOF){


		insafter(&head, ele);

	}
	printList(head);
	reverse(&head);
	printf("\n Reversed Linked list by non rerusive \n");
	printList(head);
	printf("\nReverse Linked list by recursive\n");
	recursiveReverse(&head);
	printList(head);
	getchar();
}
Beispiel #3
0
void insert(nodeptr list, int n)
{
  int i=1;
  char x;
  for(i=1;i<=n;i++)
  {
    printf("Enter the item to be inserted at node %d ",i);
    x=getche();
    printf("\n");
    if(i==1)
      insbgn(&list,x);
    else if(i==n)
      insend(&list,x);
    else
      {
	nodeptr p,q;
	p=list;
	q->next=p;
	insafter(q,x);
      }
  }
  printf("Nodes inserted with the given info\n");
}