第三周项目三 求集合并集
来源:互联网 发布:网络的3类地址 编辑:程序博客网 时间:2024/06/05 16:40
/* 文件名称:求集合并集作 者:胡德杰 完成日期:2017年9月20号 版 本 号:v1.1.5*/#include "list.h"#include <stdio.h>void unionList(SqList *LA, SqList *LB, SqList *&LC){ int lena,i; ElemType e; InitList(LC); for (i=1; i<=ListLength(LA); i++) //将LA的所有元素插入到Lc中 { GetElem(LA,i,e); ListInsert(LC,i,e); } lena=ListLength(LA); //求线性表LA的长度 for (i=1; i<=ListLength(LB); i++) { GetElem(LB,i,e); //取LB中第i个数据元素赋给e if (!LocateElem(LA,e)) //LA中不存在和e相同者,插入到LC中 ListInsert(LC,++lena,e); }}//用main写测试代码int main(){ SqList *sq_a, *sq_b, *sq_c; ElemType a[6]= {5,8,7,2,4,9}; CreateList(sq_a, a, 6); printf("LA: "); DispList(sq_a); ElemType b[6]= {2,3,8,6,0}; CreateList(sq_b, b, 5); printf("LB: "); DispList(sq_b); unionList(sq_a, sq_b, sq_c); printf("LC: "); DispList(sq_c); return 0;}知识点总结:实现unionList()函数,与算法库的应用。学习心得:锻炼了算法库的应用,并自己实现了unionList函数。
阅读全文
0 0
- 第三周项目三求集合并集
- 第三周 项目三--求集合并集
- 第三周项目三 求集合并集
- 第三周项目三 求集合并集
- 第三周 项目三 求集合并集。
- 第三周项目三—求集合并集
- 第三周 项目三-【求集合并集】
- 第三周项目三 求集合并集
- 第三周项目三--求集合并集
- 第三周 项目三-求集合并集
- 第三周【项目三-求集合并集】
- 第三周项目三 求集合并集
- 第三周 项目三——求集合并集
- 第三周项目三 求集合并集
- 第三周项目三-求集合并集
- 第三周-项目三求集合并集
- 第三周 项目三 -求集合并集
- 第三周项目三求集合并集
- Linux操作系统命令学习第一天
- [数据结构]数据结构——链表法
- Java练习
- LeetCode 515. Find Largest Value in Each Tree Row
- Sql 语句练习
- 第三周项目三 求集合并集
- Python2到Python3代码的转换工具2to3.py
- CSDN-markdown编辑器示意效果
- java程序练习:尝试创建一个父类,在父类中创建两个方法,在子类中覆盖第二个方法,为子类创建一个对象,将他向上转型到基类并调用这个方法。
- nginx配置location总结及rewrite规则写法
- JTable用法
- Navicat for mysql 下载、安装、连接MySQL操作
- HDU2222(AC自动机入门题)
- CentOS 7 yum 安装 Nginx