第3周项目一 :顺序表的基本运算
来源:互联网 发布:淘宝小号点数是什么 编辑:程序博客网 时间:2024/06/05 05:04
- *Copyright (c) 2017, 烟台大学计算机学院
- *All rights reserved.
- *文件名称:渣.cpp
- *作 者:张行
- *完成日期:2017年9月14日
- *版 本 号:v1.0
- *
- *问题描述:输出线性表
- *输入描述:如图所示
main.cpp:
#include <stdio.h>
#include <malloc.h>
#include "123123.h"
int main()
{
SqList *sq;
ElemType x[6]= {5,8,7,2,4,9};
CreateList(sq, x, 6);
DispList(sq);
#include <malloc.h>
#include "123123.h"
int main()
{
SqList *sq;
ElemType x[6]= {5,8,7,2,4,9};
CreateList(sq, x, 6);
DispList(sq);
return 0;
}
}
fun.cpp:
#include "123123.h"
#include "malloc.h"
//下面实现要测试的各个自定义函数
//用数组创建线性表
void CreateList(SqList *&L, ElemType a[], int n)
{
int i;
L=(SqList *)malloc(sizeof(SqList));
for (i=0; i<n; i++)
L->data[i]=a[i];
L->length=n;
}
//输出线性表DispList(L)
void DispList(SqList *L)
{
int i;
if (ListEmpty(L))
return;
for (i=0; i<L->length; i++)
printf("%d ",L->data[i]);
printf("\n");
}
//判定是否为空表ListEmpty(L)
bool ListEmpty(SqList *L)
{
return(L->length==0);
}
#include "malloc.h"
//下面实现要测试的各个自定义函数
//用数组创建线性表
void CreateList(SqList *&L, ElemType a[], int n)
{
int i;
L=(SqList *)malloc(sizeof(SqList));
for (i=0; i<n; i++)
L->data[i]=a[i];
L->length=n;
}
//输出线性表DispList(L)
void DispList(SqList *L)
{
int i;
if (ListEmpty(L))
return;
for (i=0; i<L->length; i++)
printf("%d ",L->data[i]);
printf("\n");
}
//判定是否为空表ListEmpty(L)
bool ListEmpty(SqList *L)
{
return(L->length==0);
}
123123.cpp:
#include <stdio.h>
#define MaxSize 50 //Maxsize将用于后面定义存储空间的大小
typedef int ElemType; //ElemType在不同场合可以根据问题的需要确定,在此取简单的int
typedef struct
{
ElemType data[MaxSize]; //利用了前面MaxSize和ElemType的定义
int length;
} SqList;
void CreateList(SqList *&L, ElemType a[], int n);//用数组创建线性表
void DispList(SqList *L);//输出线性表DispList(L)
bool ListEmpty(SqList *L);//判定是否为空表ListEmpty(L)
阅读全文
2 0
- 第3周项目一 :顺序表的基本运算
- 第3周 【项目一】 顺序表的基本运算
- 第3周 项目1-顺序表的基本运算
- 【第3周 项目1 - 顺序表的基本运算】
- 第3周 项目1 - 顺序表的基本运算
- 第3周项目1顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周 项目1 - 顺序表的基本运算
- 第3周项目1 顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1 顺序表的基本运算
- 第3周 项目1-顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1-顺序表的基本运算
- 第3周项目1 -顺序表的基本运算
- dbcp连接池属性
- nginx学习随笔--ssl_session_cache
- springMVC 的工作原理和机制
- wpf数据绑定source和elementname的区别
- CasperJS
- 第3周项目一 :顺序表的基本运算
- 计算机组成原理知识点梳理(三)
- c++中的左值与右值的区别
- android.content.ReceiverCallNotAllowedException: 解决方法
- 迭代器模式
- C语言:二维数组的存储及地址表示
- 【学习】springmvc之基于setter的依赖注入
- DataTables API中文翻译
- CVE-2016-10190 FFmpeg Http协议 heap buffer overflow漏洞分析及利用