电子书籍 源码 人工审核无毒

数据结构实验

所属分类 源码
文件大小 94 K
文件格式 DOC 文件
累计下载 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

    相关源码资料推荐

下载与解压说明

下载积分规则

  • 本资源下载仅需 2 积分
  • 24 小时内重复下载免扣积分
  • VIP 会员享专属免积分高速通道

文件解压指南

  • 推荐使用 7-Zip 或新版 WinRAR 解压
  • 原理图与 PCB 请使用对应 EDA 软件打开
  • 压缩包内源码可直接在上方在线预览

免费获取积分