zoukankan      html  css  js  c++  java
  • 2008秋季计算机软件基础0908课堂用例(2)

    #include<stdio.h>
    #include
    <stdlib.h>
    struct nodetype
    {
        
    int data;
        
    /* data数据项用于存放结点的数据值 */
        
    struct nodetype *next; 
        
    /* next数据项存放下一个结点的指针 */
    };
    struct nodetype * InitialLinkList ()
    {
     
    struct nodetype * head;
     head
    =(struct nodetype *)malloc(sizeof(struct nodetype ));//
     head->next=NULL;
     
    return head;
    }

    void CreateLinkListInRear(struct nodetype * head, int a[], int n)
    {   
    int i;  struct nodetype * temp,* rear;
        rear
    =head;
        
    for(i=0;i<n;i++)
        {
            temp
    =(struct nodetype *)malloc(sizeof(struct nodetype));
            temp
    ->data=a[i];
            temp
    ->next=NULL;
            rear
    ->next=temp;
        rear
    =temp;
        }
    }

    void CreateLinkListInHead(struct nodetype * head,
                              
    int a[], int n)
    {   
    int i;struct nodetype * temp,*front;
        
    for(i=0;i<n;i++)
        {
            temp
    =(struct nodetype *)malloc(
                
    sizeof(struct nodetype));
            temp
    ->data=a[i];
            temp
    ->next=head->next;
            head
    ->next=temp;
        }
    }

    void printlinklist(struct nodetype * head)
    {
      
    struct nodetype * p;
      p
    =head->next;
      
    while(p!=NULL)
      {
        printf(
    " %d ",p->data);
        p
    =p->next;
      }
    }

    void main()
    {
      
    struct nodetype * head;
      
    int a[3]={3,2,1};
      head
    =InitialLinkList();
      
    //CreateLinkListInRear(head,a,3);
      CreateLinkListInHead(head,a,3);
      printlinklist(head);
    }

    参看: http://www.cnblogs.com/emanlee/archive/2007/09/10/888942.html

  • 相关阅读:
    10uF的电容能滤除什么频率的电源纹波?
    Integrate Logic Analyzer入门
    状态机
    Setup和Hold(Max/Min)分析
    RS232
    Vivado时序分析概念setup time, hold time
    python学习第34天
    python学习第33天
    python学习第32天
    python学习第31天
  • 原文地址:https://www.cnblogs.com/emanlee/p/1286903.html
Copyright © 2011-2022 走看看