Sequence flip pointer

Source: Internet
Author: User
# Include <stdio. h> # include <string. h> # include <stdlib. h> # define list_init_size 100 # define add 10 typedef struct lnode {int date; struct lnode * Next;} lnode, * linklist; linklist creatlist_l () {linklist phead, P, L; L = (linklist) malloc (sizeof (lnode); int val, I, n; phead = (linklist) malloc (sizeof (lnode); phead = NULL; printf ("Enter the length of the linked list to be created: \ n"); scanf ("% d", & N); printf ("Enter the data you want to enter: \ n "); for (I = 0; I <n; ++ I) {s CANF ("% d", & Val); P = (linklist) malloc (sizeof (lnode); P-> date = val; If (phead = NULL) // search for the early node L = phead = P; else l-> next = P; L = P;} l-> next = NULL; return phead ;} // creatlist_llinklist resver_l (linklist head) {<span style = "white-space: pre"> </span> linklist P, Q, R; P = head; Q = r = NULL; while (p) {q = p-> next; P-> next = r; r = P; P = Q;} return r ;} // resver_lvoid output_l (linklist head) {linklist P; <span St YLE = "white-space: pre"> </span> P = (linklist) malloc (sizeof (lnode); <span style = "white-space: pre "> </span> P = head; <span style =" white-space: pre "> </span> while (P! = NULL) {<span style = "white-space: pre"> </span> printf ("% d", p-> date ); <span style = "white-space: pre"> </span> P = p-> next;} puts ("") ;}// output_lint main () {<span style = "white-space: pre"> </span> int N; <span style = "white-space: pre"> </span> linklist l, head; <span style = "white-space: pre"> </span> head = (linklist) malloc (sizeof (lnode); <span style = "white-space: pre "> </span> head = creatlist_l (); <span style =" white-space: pre "> </span> printf (" sequence before turning: \ n "); <span style =" white-space: pre "> </span> output_l (head); <span style =" white-space: pre "> </span> printf (" reverse sequence: \ n "); <span style =" white-space: pre "> </span> head = resver_l (head); <span style =" white-space: pre "> </span> output_l (head );}

Sequence flip pointer

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.