C Classic 14-bidirectional list storage 1-10---Shinepans

Source: Internet
Author: User

#include <stdio.h> #include <conio.h> #include <stdlib.h>//system (); This command needs to be used for this header file # include <ctype.h>//toupper to use # include <malloc.h>//header file used in memory management void main () {int i;struct  Listentry{int number;  Data domain struct ListEntry *next; Pointer to the next listentry node struct listentry *previous;  Pointer to the previous ListEntry node}start,*node, *newone;start.next = NULL;  Empty list start.previous = Null;node = &start; Start of the list for (i = 1; i <; i + = 2) {Node->next = (struct listentry*) malloc (sizeof (struct listentry)); node->next- >previous = Node;node = Node->next;node->number = I;node->next = NULL;} for (i = 2; I <=; i + = 2) {int found = 0;newone = (struct listentry*) malloc (sizeof (struct listentry)); Newone->numb ER = I;node = start.next;do{if (Node->number > Newone->number) {newone->next = node;newone->previous = node ->previous;node->previous->next = newone;node->previous = Newone;found = 1;} Else{node = Node->next;}} while ((Node->nexT) && (!found)); if (!found) if (Node->number > Newone->number) {newone->next = node;newone-> previous = Node->previous;node->previous->next = Newone;node->previous = Newone;} Else{newone->next = null;newone->previous = Node;node->next = Newone;}} node = start.next;do{printf ("%d", node->number); node = Node->next;} while (node); system ("Pause");}





This code is very classic, the 1-10 is not in book order into the two-way list, and again the orchestration, so that it finally output to 12345678910

C Classic 14-bidirectional list storage 1-10---Shinepans

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.