C 语言链表其他实现
生活随笔
收集整理的這篇文章主要介紹了
C 语言链表其他实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
C 語言鏈表其他實現
#include<stdio.h> #include<stdlib.h> #define N 10typedef struct list{int data;struct list *next;}SLIST;main(){SLIST *head ,*p,*q;int i;int a[10]={1,2,3,4,5,6,7,8,9};head=p=(SLIST *)malloc(sizeof(SLIST));for(i=0;i<N;i=i+1){q=(SLIST *)malloc(sizeof(SLIST));// printf("%p\n",q);q->data=a[i];p->next=q;p=q; // printf("%p\n",q);}p=head->next; //下面為打印一個鏈表while(p!=NULL){// printf("%p",p);printf("%d\n",p->data);//輸出當前節點的數據q=p; //刪除當前節點p=p->next;free(q); //釋放刪除的}return ;}posted on 2018-08-04 21:22 luoganttcc 閱讀(...) 評論(...) 編輯 收藏
總結
以上是生活随笔為你收集整理的C 语言链表其他实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c 语言链表的另一种实现
- 下一篇: c语言的指针理解