• 数据结构——A-Z的单链表


     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 
     4 typedef char Elemtype;
     5 
     6 typedef struct node
     7 {
     8     Elemtype data;
     9     struct node *next;
    10 }Lnode,*Linklist;
    11 
    12 void createHead(Linklist *L)
    13 {
    14     Linklist s;
    15     int i;
    16     printf("头插法:
    ");
    17     *L = (Linklist)malloc(sizeof(Lnode)); 
    18     (*L)->next = NULL;
    19 
    20     for(i=0;i<26;i++)
    21     {
    22         s = (Linklist)malloc(sizeof(Lnode));
    23         
    24         s->data = 65+i;
    25         s->next = (*L)->next;
    26         (*L)->next = s;
    27     }
    28 }
    29 void createRear(Linklist *L)
    30 {
    31     Linklist s,rear;
    32     int i;
    33     printf("尾插法:
    ");
    34 
    35     *L = (Linklist)malloc(sizeof(Lnode));
    36     rear = *L;
    37 
    38     for(i=0;i<26;i++)
    39     {
    40         s = (Linklist)malloc(sizeof(Lnode));
    41         s->data = 65+i;
    42         rear->next = s;
    43         rear = s;
    44     }
    45     rear->next = NULL;
    46 
    47 }
    48 void print(Linklist L)
    49 {
    50     Linklist p = L->next;
    51     while(p)
    52     {
    53         printf("%c ",p->data);
    54         p = p->next;
    55     }
    56     printf("
    ");
    57 }
    58 int main()
    59 {
    60     Linklist La,Lb;
    61     
    62     createHead(&La);
    63     print(La);
    64 
    65     createRear(&Lb);
    66     print(Lb);
    67 
    68     return 0;
    69 }
    View Code
  • 相关阅读:
    IDL---ENVI
    IDL基础
    IDL_GUI
    .Net MVC+bootstrap Table学习
    .Net中的加密解密
    Linux服务器上安装织梦CMS
    数据仓储之DLL层接口设计
    js获取新浪天气接口
    js动态生成二维码图片
    Jquery点击发送按钮后,按钮文本倒计时
  • 原文地址:https://www.cnblogs.com/biu-biu-biu-/p/6063412.html
Copyright © 2020-2023  润新知