亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

您現在的位置是:蟲蟲下載站 > 資源下載 > 源碼 > 數據結構實驗

數據結構實驗

  • 資源大小:94 K
  • 上傳時間: 2018-05-09
  • 上傳用戶:123456..
  • 資源積分:2 下載積分
  • 標      簽: 數據結構 實驗

資 源 簡 介

  1. #include <stdio.h>  
  2. #include <stdlib.h> ///鏈式棧  
  3.   
  4. typedef struct node  
  5. {  
  6.     int data;  
  7.     struct node *next;  
  8. }Node,*Linklist;  
  9.   
  10. Linklist Createlist()  
  11. {  
  12.     Linklist p;  
  13.     Linklist h;  
  14.     int data1;  
  15.     scanf("%d",&data1);  
  16.     if(data1 != 0)  
  17.     {  
  18.         h = (Node *)malloc(sizeof(Node));  
  19.         h->data = data1;  
  20.         h->next = NULL;  
  21.     }  
  22.     else if(data1 == 0)  
  23.     return NULL;  
  24.     scanf("%d",&data1);  
  25.     while(data1 != 0)  
  26.     {  
  27.         p = (Node *)malloc(sizeof(Node));  
  28.         p -> data = data1;  
  29.         p -> next = h;  
  30.         h = p;  
  31.         scanf("%d",&data1);  
  32.     }  
  33.     return h;  
  34. }  
  35.   
  36. void Outputlist(Node *head)  
  37. {  
  38.     Linklist p;  
  39.     p = head;  
  40.     while(p != NULL )  
  41.     {  
  42.         printf("%d ",p->data);  
  43.         p = p->next;  
  44.     }  
  45.     printf("\n");  
  46. }  
  47.   
  48. void Freelist(Node *head)  
  49. {  
  50.     Node *p;  
  51.     Node *q = NULL;  
  52.     p = head;  
  53.     while(p != NULL)  
  54.     {  
  55.         q = p;  
  56.         p = p->next;  
  57.         free(q);  
  58.     }  
  59. }  
  60.   
  61. int main()  
  62. {  
  63.     Node *head;  
  64.     head = Createlist();  
  65.   
  66.     Outputlist(head);  
  67.   
  68.     Freelist(head);  
  69.   
  70.     return 0;  
  71. }  



2.順序棧

[cpp] view plain copy
  1. #include <iostream>  
  2. #include <stdio.h>  
  3. #include <stdlib.h> ///順序棧  
  4. #define MaxSize 100  
  5.   
  6. using namespace std;  
  7.   
  8. typedef

相 關 資 源

主站蜘蛛池模板: 蛟河市| 尤溪县| 平江县| 皋兰县| 娱乐| 新昌县| 安图县| 崇信县| 邵东县| 泉州市| 银川市| 德昌县| 凤山县| 屯昌县| 扎鲁特旗| 麻栗坡县| 额敏县| 施甸县| 六枝特区| 盐池县| 栾城县| 温宿县| 祁东县| 调兵山市| 周口市| 新源县| 泗阳县| 安陆市| 谢通门县| 高碑店市| 汶上县| 漯河市| 岑巩县| 固安县| 蓝田县| 乌拉特中旗| 阳春市| 合山市| 庆阳市| 铜鼓县| 昆山市|