亚洲欧美第一页_禁久久精品乱码_粉嫩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

相 關 資 源

您 可 能 感 興 趣 的

主站蜘蛛池模板: 丰都县| 凌海市| 巴青县| 吴江市| 武功县| 胶南市| 通许县| 怀化市| 西峡县| 奈曼旗| 奉化市| 静宁县| 邯郸县| 股票| 墨竹工卡县| 应城市| 临城县| 福州市| 紫阳县| 神木县| 广丰县| 舞钢市| 土默特右旗| 邢台县| 哈尔滨市| 鹤庆县| 固原市| 石楼县| 杭州市| 荥经县| 勐海县| 通化县| 梨树县| 山西省| 松阳县| 鄂托克旗| 盐池县| 合川市| 历史| 上思县| 万山特区|