Re-learning data structure simple linked list flashbacks, positive sequence insertion, general display, recursive display of __ data structures

Source: Internet
Author: User
 
#include <stdio.h> #include <malloc.h> typedef struct Node {int date;
struct node *next;
}node,*lnode; void CreateList (Lnode &l,int N); Insert a positive sequence into the list behind the list void Createlist2 (Lnode &l,int N);			 At the front of the list is a constant insertion of node void display (Lnode l);
Display chain table void Display2 (Lnode l);
	int main () {Lnode L;
	CreateList (l,5);
	Display (l);
	printf ("\ n");
Display2 (L->next);
	/* node l1,l2,l3;
	Lnode p;
	l1.date=1;
	l1.next=&l2;
	l2.date=2;
	l2.next=&l3;
	l3.date=3;
	L3.next=null;
p=&l1;
for (P=l1;p->next!=null;p=p->next)//{printf ("%d", p->next->date);//} */return 0;
	} void CreateList (Lnode &l,int n) {int i;
	Lnode p,q;
	L= (Lnode) malloc (sizeof (node));
	l->next=null;
	Q=l;
	printf ("Enter data \ n");	
		for (i=0;i<n;i++) {p= (lnode) malloc (sizeof (node));
		scanf ("%d", &p->date);
		q->next=p;
	q=q->next;
} q->next=null;
	} void Createlist2 (Lnode &l,int n) {int i;
	Lnode Q;
	L= (Lnode) malloc (sizeof (node));
	l->next=null; printf ("Loseinto data \ n ");	
		for (i=0;i<n;i++) {p= (lnode) malloc (sizeof (node));
		scanf ("%d", &p->date);
		p->next=l->next;
	l->next=p;
	} void Display (Lnode l) {Lnode p;
	for (P=l->next;p!=null;p=p->next) {printf ("%d", p->date);		
	} void Display2 (Lnode l) {if (l==null) {return;
	else {printf ("%d", l->date);
		l=l->next;
	Display2 (L->next); }
}


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.