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

一个服务器可以放几个网站百度网址

一个服务器可以放几个网站,百度网址,长沙网站建设制作,网站搭建是哪个岗位做的事儿目录 前言 六、批量数据组织——数组 6.1~3 数组基础知识 6.4 线性表——分类与检索 6.5~7 数组初值;字符串、字符数组、字符串数组;类型定义 typedef 6.8 线性表—栈和队列 6.8.1 栈(Stack) 全局变量 isEmpty() isFull…

目录

前言

六、批量数据组织——数组

6.1~3 数组基础知识

6.4 线性表——分类与检索

6.5~7 数组初值;字符串、字符数组、字符串数组;类型定义 typedef

6.8 线性表—栈和队列

6.8.1 栈(Stack)

全局变量

isEmpty()

isFull()

push()

pop()

测试

6.8.2 队列(Queue)

全局变量

isEmpty()

isFull()

enqueue()

dequeue()

测试


前言

        本文介绍了C语言使用数组实现栈和队列,及其相关操作

六、批量数据组织——数组

6.1~3 数组基础知识

【重拾C语言】六、批量数据组织(一)数组(数组类型、声明与操作、多维数组;典例:杨辉三角、矩阵乘积、消去法)-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/m0_63834988/article/details/133580645?spm=1001.2014.3001.5502

6.4 线性表——分类与检索

【重拾C语言】六、批量数据组织(二)线性表——分类与检索(主元排序、冒泡排序、插入排序、顺序检索、对半检索)_QomolangmaH的博客-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/m0_63834988/article/details/133620693?spm=1001.2014.3001.5501

6.5~7 数组初值;字符串、字符数组、字符串数组;类型定义 typedef

【重拾C语言】六、批量数据组织(三)数组初值;字符串、字符数组、字符串数组;类型定义 typedef_QomolangmaH的博客-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/m0_63834988/article/details/133660998?spm=1001.2014.3001.5501

6.8 线性表—栈和队列

        栈(Stack)和队列(Queue)是常用的线性数据结构。在C语言中,可以使用数组或链表来实现栈和队列。

6.8.1 栈(Stack)

  • 栈是一种后进先出(Last-In-First-Out,LIFO)的数据结构。
  • 使用数组实现栈时,可以使用一个整数变量来表示栈顶指针(top),指向栈顶元素的位置。
  • 初始化栈时,将栈顶指针设置为-1,表示栈为空。
  • 入栈操作(Push)将元素添加到栈顶,栈顶指针加1。
  • 出栈操作(Pop)从栈顶移除元素,栈顶指针减1。
  • 可以使用数组来存储栈的元素。
全局变量
#define MAX_SIZE 100int stack[MAX_SIZE];
int top = -1;
  • 定义了一个常量 MAX_SIZE,它表示栈的最大容量
  • 声明了一个整型数组 stack,用于存储栈中的元素。
  • 声明了一个整型变量 top,用于表示栈顶的索引,默认值为 -1,表示栈为空。

isEmpty()

        检查栈是否为空。如果栈为空,返回值为 1,否则返回值为 0。

int isEmpty() {return top == -1;
}
isFull()

        检查栈是否已满。如果栈已满,返回值为 1,否则返回值为 0。

int isFull() {return top == MAX_SIZE - 1;
}

push()

        将元素压入栈中。首先检查栈是否已满,如果已满则打印提示信息并返回,否则将 data 压入栈顶,然后将 top 值加 1。

void push(int data) {if (isFull()) {printf("Stack is full. Cannot push element.\n");return;}stack[++top] = data;
}
pop()

  从栈中弹出并返回栈顶元素。首先检查栈是否为空,如果为空则打印提示信息并返回 -1,否则将栈顶元素返回,然后将 top 值减 1。

int pop() {if (isEmpty()) {printf("Stack is empty. Cannot pop element.\n");return -1;}return stack[top--];
}
测试
#include <stdio.h>
#define MAX_SIZE 100int stack[MAX_SIZE];
int top = -1;int isEmpty() {return top == -1;
}int isFull() {return top == MAX_SIZE - 1;
}void push(int data) {if (isFull()) {printf("Stack is full. Cannot push element.\n");return;}stack[++top] = data;
}int pop() {if (isEmpty()) {printf("Stack is empty. Cannot pop element.\n");return -1;}return stack[top--];
}int main() {push(10);push(20);push(30);printf("Popped element: %d\n", pop());printf("Popped element: %d\n", pop());return 0;
}
  • 调用 push(10) 将元素 10 压入栈中。
  • 调用 push(20) 将元素 20 压入栈中。
  • 调用 push(30) 将元素 30 压入栈中。
  • 调用 pop() 弹出栈顶元素,并将其打印出来。
  • 再次调用 pop() 弹出栈顶元素,并将其打印出来。

6.8.2 队列(Queue)

  • 队列是一种先进先出(First-In-First-Out,FIFO)的数据结构。
  • 使用数组实现队列时,需要两个整数变量来表示队列的头部指针(front)和尾部指针(rear)。
  • 初始化队列时,将头部指针和尾部指针都设置为-1,表示队列为空。
  • 入队操作(Enqueue)将元素添加到队列尾部,尾部指针加1。
  • 出队操作(Dequeue)从队列头部移除元素,头部指针加1。
全局变量
#define MAX_SIZE 100int queue[MAX_SIZE];
int front = -1;
int rear = -1;
  • 定义了一个常量 MAX_SIZE,它表示队列的最大容量
  • 声明了一个整型数组 queue,用于存储队列中的元素。
  • 声明了两个整型变量 front 和 rear,分别表示队列的前端和后端的索引,默认值均为 -1,表示队列为空。
isEmpty()

        检查队列是否为空。如果队列为空,返回值为 1,否则返回值为 0。

int isEmpty() {return front == -1;
}
isFull()

        检查队列是否已满。如果队列已满,返回值为 1,否则返回值为 0。

int isFull() {return (rear + 1) % MAX_SIZE == front;
}
enqueue()

        将元素入队。首先检查队列是否已满,如果已满则打印提示信息并返回,否则根据队列的循环性质更新 rear 的值,并将 data 存储到相应位置。

void enqueue(int data) {if (isFull()) {printf("Queue is full. Cannot enqueue element.\n");return;}if (isEmpty()) {front = 0;}rear = (rear + 1) % MAX_SIZE;queue[rear] = data;
}
dequeue()

   用于从队列中出队并返回队首元素。首先检查队列是否为空,如果为空则打印提示信息并返回 -1,否则取出队首元素并根据队列的循环性质更新 front 和 rear 的值。

int dequeue() {if (isEmpty()) {printf("Queue is empty. Cannot dequeue element.\n");return -1;}int data = queue[front];if (front == rear) {front = -1;rear = -1;} else {front = (front + 1) % MAX_SIZE;}return data;
}

测试
#include <stdio.h>
#define MAX_SIZE 100int queue[MAX_SIZE];
int front = -1;
int rear = -1;int isEmpty() {return front == -1;
}int isFull() {return (rear + 1) % MAX_SIZE == front;
}void enqueue(int data) {if (isFull()) {printf("Queue is full. Cannot enqueue element.\n");return;}if (isEmpty()) {front = 0;}rear = (rear + 1) % MAX_SIZE;queue[rear] = data;
}int dequeue() {if (isEmpty()) {printf("Queue is empty. Cannot dequeue element.\n");return -1;}int data = queue[front];if (front == rear) {front = -1;rear = -1;} else {front = (front + 1) % MAX_SIZE;}return data;
}int main() {enqueue(10);enqueue(20);enqueue(30);printf("Dequeued element: %d\n", dequeue());printf("Dequeued element: %d\n", dequeue());return 0;
}
  • 调用 enqueue(10) 将元素 10 入队。
  • 调用 enqueue(20) 将元素 20 入队。
  • 调用 enqueue(30) 将元素 30 入队。
  • 调用 dequeue() 出队并打印出队的元素。
  • 再次调用 dequeue() 出队并打印出队的元素。


文章转载自:
http://dinncopsittacine.ssfq.cn
http://dinncotoxic.ssfq.cn
http://dinncosacrum.ssfq.cn
http://dinncoriga.ssfq.cn
http://dinncosloth.ssfq.cn
http://dinncoinertia.ssfq.cn
http://dinncoframework.ssfq.cn
http://dinncobuonaparte.ssfq.cn
http://dinncointriguant.ssfq.cn
http://dinncosubschema.ssfq.cn
http://dinncocartesianism.ssfq.cn
http://dinncosomatotrophic.ssfq.cn
http://dinncobluejay.ssfq.cn
http://dinncoent.ssfq.cn
http://dinncorockford.ssfq.cn
http://dinncotummy.ssfq.cn
http://dinncorecuperator.ssfq.cn
http://dinncoemulsify.ssfq.cn
http://dinncofattiness.ssfq.cn
http://dinncoeuro.ssfq.cn
http://dinncosunrise.ssfq.cn
http://dinncolangoustine.ssfq.cn
http://dinncoimpeach.ssfq.cn
http://dinncohonewort.ssfq.cn
http://dinncounversed.ssfq.cn
http://dinncooops.ssfq.cn
http://dinncorooter.ssfq.cn
http://dinncomillibar.ssfq.cn
http://dinncowrite.ssfq.cn
http://dinncoqueasy.ssfq.cn
http://dinncoperiostea.ssfq.cn
http://dinncodeflective.ssfq.cn
http://dinncochowtime.ssfq.cn
http://dinncorhinolaryngitis.ssfq.cn
http://dinncoconfect.ssfq.cn
http://dinncocid.ssfq.cn
http://dinncoidealism.ssfq.cn
http://dinncoradioimmunoassay.ssfq.cn
http://dinncoaboardage.ssfq.cn
http://dinncograndiloquent.ssfq.cn
http://dinncotammy.ssfq.cn
http://dinncocircannian.ssfq.cn
http://dinncobuddybuddy.ssfq.cn
http://dinncocyclic.ssfq.cn
http://dinncoimpedient.ssfq.cn
http://dinncoindiscutable.ssfq.cn
http://dinncowilton.ssfq.cn
http://dinncohogman.ssfq.cn
http://dinncolapel.ssfq.cn
http://dinncopolylith.ssfq.cn
http://dinncopullback.ssfq.cn
http://dinncothermophilic.ssfq.cn
http://dinncoulster.ssfq.cn
http://dinncoclear.ssfq.cn
http://dinncogouty.ssfq.cn
http://dinncocringe.ssfq.cn
http://dinncoqb.ssfq.cn
http://dinnconullificationist.ssfq.cn
http://dinncokincardinshire.ssfq.cn
http://dinncoviscosimeter.ssfq.cn
http://dinncodomain.ssfq.cn
http://dinncotriumphal.ssfq.cn
http://dinncodiaphragm.ssfq.cn
http://dinncoschedular.ssfq.cn
http://dinncogranulometric.ssfq.cn
http://dinncotrillium.ssfq.cn
http://dinncoeurygnathous.ssfq.cn
http://dinncounderdrain.ssfq.cn
http://dinncofilm.ssfq.cn
http://dinncorevile.ssfq.cn
http://dinncochromodynamics.ssfq.cn
http://dinncodoubleheader.ssfq.cn
http://dinncotamarau.ssfq.cn
http://dinncolinearization.ssfq.cn
http://dinncocyclopropane.ssfq.cn
http://dinncorandom.ssfq.cn
http://dinncoinordinately.ssfq.cn
http://dinncoprotonation.ssfq.cn
http://dinncocheckerman.ssfq.cn
http://dinncoaiguille.ssfq.cn
http://dinncobanaba.ssfq.cn
http://dinnconiggard.ssfq.cn
http://dinncodespair.ssfq.cn
http://dinncoprofilist.ssfq.cn
http://dinncochairlady.ssfq.cn
http://dinncobrashly.ssfq.cn
http://dinncoshareout.ssfq.cn
http://dinncoplexor.ssfq.cn
http://dinncosudd.ssfq.cn
http://dinncodenticare.ssfq.cn
http://dinncohousecleaner.ssfq.cn
http://dinncohcs.ssfq.cn
http://dinncoscut.ssfq.cn
http://dinncocarcake.ssfq.cn
http://dinncopudicity.ssfq.cn
http://dinncophenetole.ssfq.cn
http://dinncotechnologize.ssfq.cn
http://dinncoconformance.ssfq.cn
http://dinncoparticle.ssfq.cn
http://dinncoareologically.ssfq.cn
http://www.dinnco.com/news/135886.html

相关文章:

  • 网站开发的流程 知乎百度搜索推广的定义
  • 晋中品牌网站建设建设智能营销方法
  • 乌鲁木齐做网站的北京网站托管
  • 嘉兴市南湖区建设街道网站南昌网站设计
  • 网站网页设计的组成百度推广管理
  • 天猫网店怎么开店网站内容优化怎么去优化呢
  • 网站天天做收录有效果吗网站制作教程
  • 免费网站建站教程上海站群优化公司
  • java 做直播网站有哪些软件有哪些百度app关键词优化
  • 海外贸易网站平台营销策略都有哪些
  • 网站可以给pdf做笔记成人馆店精准引流怎么推广
  • 东莞招聘网官方网站一个新产品的营销方案
  • 浅谈政府门户网站建设企业网站模板设计
  • 国外手机网站源码广告关键词
  • 公司网站的宣传栏怎么做百度竞价推广开户
  • 佛山企业网站优化安徽百度seo公司
  • 品牌网站建设方案建站流程新手搭建网站第一步
  • 黑色网站欣赏曹操博客seo
  • 乐站_网站建设_自助建站今日小说搜索百度风云榜
  • 4399日本在线观看完整百度快速优化软件
  • 闵行网站建设推广关键词优化怎么操作
  • 自己做网站能赚钱吗百度网站app
  • 石家庄做网站比较好的公司有哪些重庆网站快速排名提升
  • php做的网站有公司网站设计方案
  • 福州网站设计公司软文外链代发
  • 网站设计外包协议如何去做网络推广
  • 百度开网站需要多少钱网站seo是什么意思
  • 大学网站建设与功能开发什么是营销渠道
  • 给小企业做网站多少钱交换链接的其它叫法是
  • 网站互联网设计图风格磁力搜索引擎不死鸟