⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3_4.txt

📁 C语言数据结构知识原代码 C语言数据结构知识原代码C语言数据结构知识原代码
💻 TXT
字号:
#include<stdio.h>
typedef struct node{                   /*结点类型*/
   int data;
   struct node *next;
   }Llist;
  
  createlist(Llist **h,int a[],int n)
   {
    int i;Llist *s,*r;
    for(i=0;i<n;i++)                       /*在表尾插入结点*/
     {
      s=(Llist *)malloc(sizeof(Llist));
      s->data=a[i];
      s->next=NULL;
      if(*h==NULL){*h=s;
                   r=s;}
       else { r->next=s;
              r=s;}
     }
   }
inverse(Llist **a)
 {
  Llist *h,*p,*q;
  h=*a;
  if(h==NULL) return 0;
  else{                                   /*在表头插入*/
    p=h->next;
    h->next=NULL;
    while(p){
     q=p->next;
     p->next=h;
     h=p;
     p=q;
     }
   }
  *a=h;
 }
main()
 {
  int a[]={-1,2,3,5,7,10};
  Llist *a1=NULL,*p;
  createlist(&a1,a,6);                     /*建立链表A*/
  inverse(&a1);
  p=a1;
  while(p){
   printf("%d ",p->data);
   p=p->next;
   }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -