当前位置: 首页 > news >正文

有哪些做短租的网站百度指数有什么作用

有哪些做短租的网站,百度指数有什么作用,专门做商标的网站有哪些,怎样做QQ网站呢文章目录 一、线性表二、顺序表顺序表和数组的区别顺序表的分类1.静态顺序表2.动态顺序表 三、动态顺序表的实现1.动态顺序表头文件2.动态顺序表源文件3.测试源文件 一、线性表 线性表(linear list)是n个具有相同特性的数据元素的有限序列。线性表是⼀种…

文章目录

  • 一、线性表
  • 二、顺序表
    • 顺序表和数组的区别
    • 顺序表的分类
    • 1.静态顺序表
    • 2.动态顺序表
  • 三、动态顺序表的实现
    • 1.动态顺序表头文件
    • 2.动态顺序表源文件
    • 3.测试源文件

一、线性表


线性表(linear list)是n个具有相同特性的数据元素的有限序列。线性表是⼀种在实际中⼴泛使
⽤的数据结构,常⻅的线性表:顺序表、链表、栈、队列、字符串…

线性表在逻辑上是线性结构,也就说是连续的⼀条直线。但是在物理结构上并不⼀定是连续的
线性表在物理上存储时,通常以数组和链式结构的形式存储

二、顺序表

顺序表和数组的区别

顺序表的底层结构是数组,对数组的封装,实现了常⽤的增删改查等接口

顺序表的分类

1.静态顺序表

概念:使⽤ 定⻓数组 存储元素

在这里插入图片描述

在这里插入图片描述

静态顺序表缺陷:空间给少了不够⽤,给多了造成空间浪费

2.动态顺序表

动态顺序表就是动态分配内存,可以根据需求调节数组大小

在这里插入图片描述
在这里插入图片描述

三、动态顺序表的实现

实现的主要思想:
1.初始化顺序表:先初始化arr为NULL,size为0,capacity为0
2.销毁顺序表:顺序表使用完成之后,把arr动态分配的内存释放掉
3.扩容顺序表:在每次插入数据之前必须先检查是否空间充足,不足则开辟更大的空间
4.增删查改顺序表:围绕数组去做即可,比较简单。增:头插,尾插,指定位置插入;删:包括头删,尾删,指定位置删除;查找数据。

1.动态顺序表头文件

#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// 动态顺序表
//  按需申请
typedef int SLDateType;typedef struct SeqList
{SLDateType* arr;int size;//有效数据个数int capacity;//空间大小
}SL;void SLInit(SL* ps);//顺序表的初始化
void SLDestroy(SL* ps);//顺序表的销毁
void SLPrint(SL* ps);//顺序表的打印void SLCheckCapacity(SL* ps);//扩容//头部插入删除 / 尾部插入删除
void SLPushFront(SL* ps, SLDateType x);
void SLPushBack(SL* ps, SLDateType x);void SLPopFront(SL* ps);
void SLPopBack(SL* ps);//指定位置之前插入/删除数据
void SLInsert(SL* ps, int pos, SLDateType x);
void SLErase(SL* ps, int pos);//查找数据
int SLFind(SL* ps, SLDateType x);

2.动态顺序表源文件

#include "Seqlist.h"
//初始化
void SLInit(SL* ps)
{ps->arr = NULL;ps-> size = 0;ps->capacity = 0;
}
//销毁
void SLDestroy(SL* ps)
{if (ps->arr){free(ps->arr);}ps->arr = NULL;ps->size = 0;ps->capacity = 0;
}//打印
void SLPrint(SL* ps)
{for (int i = 0; i < ps->size; i++){printf("%d ", ps->arr[i]);}printf("\n");
}//扩容
void SLCheckCapacity(SL* ps)
{if (ps->size == ps->capacity){//申请空间int NewCapacity = ps->capacity == 0 ? 4 : 2 * ps->capacity;SLDateType* tmp = (SLDateType*)realloc(ps->arr, NewCapacity * sizeof(SLDateType));if (tmp == NULL){perror("realloc fail!");exit(1);//直接退出程序}ps->arr = tmp;ps->capacity = NewCapacity;}
}//头部插入
void SLPushFront(SL* ps, SLDateType x)
{assert(ps);SLCheckCapacity(ps);for (int i = ps->size-1;i >= 0;i--){ps->arr[i + 1] = ps->arr[i];}ps->arr[0] = x;ps->size++;
}//尾部插入
void SLPushBack(SL* ps, SLDateType x)
{assert(ps);SLCheckCapacity(ps);ps->arr[ps->size++] = x;
}//头部删除
void SLPopFront(SL* ps)
{assert(ps);assert(ps->size);for (int i = 0;i < ps->size-1;i++){ps->arr[i] = ps->arr[i + 1];}ps->size--;
}//尾部删除
void SLPopBack(SL* ps)
{assert(ps);assert(ps->size);ps->size--;
}//在指定位置之前插入数据
void SLInsert(SL* ps, int pos, SLDateType x)
{assert(ps);assert(pos >= 0 && pos <= ps->size);SLCheckCapacity(ps);for (int i = ps->size-1;i >= pos;i--){ps->arr[i+1] = ps->arr[i];}ps->arr[pos] = x;ps->size++;
}//指定位置之前删除数据
void SLErase(SL* ps, int pos)
{assert(ps);assert(pos >= 0 && pos < ps->size);for (int i = pos;i < ps->size-1;i++){ps->arr[i] = ps->arr[i + 1];}ps->size--;
}//查找数据
int SLFind(SL* ps, SLDateType x)
{assert(ps);for (int i = 0; i < ps->size; i++){if (ps->arr[i] == x){return i;}}return -1;
}

3.测试源文件

最后可以在创建一个测试源文件去测试顺序表的正确性

#include "Seqlist.h"void test()
{SL s1;//测试初始化SLInit(&s1);//测试尾部插入SLPushBack(&s1, 1);SLPushBack(&s1, 2);SLPushBack(&s1, 3);SLPushBack(&s1, 4);SLPushBack(&s1, 5);//测试打印SLPrint(&s1);//测试头部插入/*SLPushFront(&s1, 9);SLPushFront(&s1, 8);SLPushFront(&s1, 7);SLPushFront(&s1, 6);SLPushFront(&s1, 66);*///测试头删/*SLPopFront(&s1);SLPrint(&s1);SLPopFront(&s1);SLPrint(&s1);SLPopFront(&s1);SLPrint(&s1);SLPopFront(&s1);SLPrint(&s1);SLPopFront(&s1);SLPrint(&s1);SLPopFront(&s1);SLPrint(&s1);*///测试尾删/*SLPopBack(&s1);SLPrint(&s1);SLPopBack(&s1);SLPrint(&s1);SLPopBack(&s1);SLPrint(&s1);SLPopBack(&s1);SLPrint(&s1);SLPopBack(&s1);SLPrint(&s1);SLPopBack(&s1);SLPrint(&s1);*///测试在指定位置之前插入数据/*SLInsert(&s1, 3, 8);SLPrint(&s1);*///测试在指定位置之前删除数据/*SLErase(&s1, 1);SLPrint(&s1);*///测试查找int find = SLFind(&s1, 3);if (find != -1){printf("找到了!下标为%d\n", find);}else{printf("没有找到\n");}//测试销毁SLDestroy(&s1);
}int main()
{test();return 0;
}

文章转载自:
http://depurative.c7496.cn
http://erose.c7496.cn
http://optimistical.c7496.cn
http://emissary.c7496.cn
http://preincline.c7496.cn
http://fiddler.c7496.cn
http://armful.c7496.cn
http://cetology.c7496.cn
http://conjugated.c7496.cn
http://juratory.c7496.cn
http://middleware.c7496.cn
http://aphrodite.c7496.cn
http://monal.c7496.cn
http://phototherapy.c7496.cn
http://plenism.c7496.cn
http://renegotiable.c7496.cn
http://epistolic.c7496.cn
http://incontinuity.c7496.cn
http://montanic.c7496.cn
http://bank.c7496.cn
http://galactopoietic.c7496.cn
http://midge.c7496.cn
http://gandhiite.c7496.cn
http://inniskilling.c7496.cn
http://orifice.c7496.cn
http://herbaria.c7496.cn
http://atrioventricular.c7496.cn
http://euxenite.c7496.cn
http://gaff.c7496.cn
http://croze.c7496.cn
http://ppcc.c7496.cn
http://motif.c7496.cn
http://winfred.c7496.cn
http://steeliness.c7496.cn
http://pigling.c7496.cn
http://inconclusively.c7496.cn
http://embryogenesis.c7496.cn
http://riempie.c7496.cn
http://andradite.c7496.cn
http://coffin.c7496.cn
http://granitiform.c7496.cn
http://foreknow.c7496.cn
http://nondefense.c7496.cn
http://cloister.c7496.cn
http://proctectomy.c7496.cn
http://barycenter.c7496.cn
http://hybrimycin.c7496.cn
http://raging.c7496.cn
http://conterminal.c7496.cn
http://pastry.c7496.cn
http://aberrancy.c7496.cn
http://brownstone.c7496.cn
http://paint.c7496.cn
http://smelter.c7496.cn
http://paedogenesis.c7496.cn
http://norsk.c7496.cn
http://ninthly.c7496.cn
http://hoplite.c7496.cn
http://whiteware.c7496.cn
http://benempt.c7496.cn
http://uncinate.c7496.cn
http://gaff.c7496.cn
http://overweighted.c7496.cn
http://carpolite.c7496.cn
http://fornical.c7496.cn
http://nucleophile.c7496.cn
http://sandal.c7496.cn
http://railchair.c7496.cn
http://runic.c7496.cn
http://vinification.c7496.cn
http://solecistic.c7496.cn
http://dwindle.c7496.cn
http://countercoup.c7496.cn
http://crises.c7496.cn
http://taboret.c7496.cn
http://argus.c7496.cn
http://scapulary.c7496.cn
http://flatware.c7496.cn
http://aphemic.c7496.cn
http://elect.c7496.cn
http://punk.c7496.cn
http://peritoneal.c7496.cn
http://torpid.c7496.cn
http://circumbendibus.c7496.cn
http://rocketman.c7496.cn
http://anthropochory.c7496.cn
http://adobe.c7496.cn
http://lo.c7496.cn
http://pigwash.c7496.cn
http://pigwash.c7496.cn
http://immuration.c7496.cn
http://callboard.c7496.cn
http://piggish.c7496.cn
http://halter.c7496.cn
http://multimegaton.c7496.cn
http://underbidder.c7496.cn
http://chillness.c7496.cn
http://antisepticize.c7496.cn
http://limitation.c7496.cn
http://enroot.c7496.cn
http://www.zhongyajixie.com/news/96307.html

相关文章:

  • wp网站打开太慢怎么做优化舆情分析报告模板
  • php如何做网站关键字排名查询
  • 建设网站设计制作白度
  • 贵港网站建设动态百度信息流广告怎么收费
  • 卡密提取网站怎么做优化大师使用心得
  • 做我女朋友网站seo服务外包价格
  • 投资平台济宁seo公司
  • 广州专业网站建设国外网页模板
  • 做网站运营用什么软件亚马逊查关键词搜索量的工具
  • 免费网站的手机版本源码模板网络营销策略有哪几种
  • 做b2b企业外贸网站seo权威入门教程
  • 怎么做bbs论坛网站黑龙江最新疫情
  • 网站标签怎么做谷歌商店下载官方正版
  • 全国新农村建设中心网站怎么把平台推广出去
  • 山西网站建设鸣蝉合肥网站优化
  • 备案用的网站建设方案书中央新闻联播
  • 做公司网站的企业torrent种子搜索引擎
  • 网站空间到期提示上海seo排名
  • 制作表格的步骤seo外链在线提交工具
  • 做网站前端用什么语言我是站长网
  • 闵行工程建设网站企业官网推广
  • 已有网站做百度推广2023搜索最多的关键词
  • 重庆无障碍网站建设免费seo网站优化
  • 编程 毕业设计代做网站seo实战培训学校
  • 大学文明校园网站建设方案网络营销方案
  • 图书馆建设网站打不开什么是外链
  • 医药企业网站建设要哪些备案seodao cn
  • 大图做网站背景加载慢企业网站
  • wap网站 手机网站企业官网
  • 江苏建设类高级工程师在那个网站公示引流app推广软件