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

数据结构day07(栈和队列)

今日任务

链式队列:

head.h

#ifndef __HEAD_H__
#define __HEAD_H__#include <stdio.h>
#include <stdlib.h>typedef int datatype;
typedef struct link_list{datatype data;struct link_list* next;
}link,*linkp;
typedef struct circulate_line_top{linkp front;linkp rear;
}link_top,*link_topp;link_topp create_top();
int push(link_topp p,datatype data);
int pull(link_topp p);
int output(link_topp p);
int del(link_topp p);#endif

fun.c

#include "head.h"
/** function:    创建top节点* @param [ in] * @param [out] * @return      */
link_topp create_top(){link_topp top=(link_topp)malloc(sizeof(link_top));if(NULL==top){puts("top point malloc failed");return NULL;}top->front=NULL;top->rear=NULL;puts("top point create success");return top;
}
/** function:    创新链表节点* @param [ in] * @param [out] * @return      */
linkp create(datatype data){linkp p=(linkp)malloc(sizeof(link));if(NULL==p){puts("link list point malloc failed");return NULL;}p->data=data;p->next=NULL;puts("link list point create success");return p;
}
/** function:    空指针判定* @param [ in] * @param [out] * @return      */
int void_point(link_topp p){if(NULL==p){puts("null point pass");return -1;}return 0;
}
/** function:    判空* @param [ in] * @param [out] * @return      */
int is_empty(link_topp p){if(NULL==p){puts("null point pass");return -1;}if(p->front==NULL){puts("stack is NULL");return 1;}return 0;
}
/** function:    入队* @param [ in] * @param [out] * @return      */
int push(link_topp p,datatype data){if(void_point(p))return -1;linkp new=create(data);//入队if(p->front==NULL)p->front=new;if(p->rear!=NULL)p->rear->next=new;p->rear=new;//	printf("t->front%d\n",p->front->data);
//	printf("t->rear%d\n",p->rear->data);
//	printf("t->front%p\n",p->front);puts("push success");return 0;
}
/** function:    出队* @param [ in] * @param [out] * @return      */
int pull(link_topp p){if(void_point(p))return -1;//判空if(p->front==NULL){puts("link stack is null ,it's no deed to pull");return 0;}//出队linkp del=p->front;//记录出队指针,freedatatype data=del->data;p->front=p->front->next;free(del);del=NULL;puts("pull success");return 0;
}
/** function:    循环输出* @param [ in] * @param [out] * @return      */
int output(link_topp p){linkp i=p->front;//不移动原指针if(void_point(p))return -1;if(is_empty(p))return 0;while(i!=NULL){printf("<-%d",i->data);i=i->next;}puts("output success");return 0;
}
/** function:    销毁* @param [ in] * @param [out] * @return      */
int del(link_topp p){if(void_point(p))return -1;linkp del;while(p->front!=NULL){del=p->front;p->front=p->front->next;free(del);}free(p);puts("del success");return 0;
}

main.c

#include "head.h"
//链表实现循环队列---尾插头删
int main(int argc, const char *argv[])
{link_topp t=create_top();push(t,11);push(t,12);push(t,13);push(t,14);printf("t->front%p\n",t->front);output(t);printf("t->front%p\n",t->front);pull(t);output(t);pull(t);output(t);pull(t);output(t);pull(t);output(t);pull(t);output(t);del(t);t=NULL;return 0;
}

运行效果:

递归

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(int a){printf("%d\n",a%10);a/=10;if(a>0)fun(a);return 0;
}
int main(int argc, const char *argv[])
{//使用递归实现程序,输入一个数,输出该数的每个数int a=123456;fun(a);return 0;
}

今日思维导图

相关文章:

数据结构day07(栈和队列)

今日任务 链式队列&#xff1a; head.h #ifndef __HEAD_H__ #define __HEAD_H__#include <stdio.h> #include <stdlib.h>typedef int datatype; typedef struct link_list{datatype data;struct link_list* next; }link,*linkp; typedef struct circulate_line_t…...

八、Linux中的用户与文件权限

1、普通用户与特权用户 (1)在Linux中&#xff0c;和windows中一样。用户分为普通用户和特权用户。 特权用户&#xff1a;拥有系统管理的绝对权限。普通用户&#xff1a;普通用户的权限受到限制&#xff0c;只拥有基本的权限&#xff0c;某些操作没有权限。 (2)Linux中的特权…...

岛屿数量 -- 二维矩阵的dfs算法

岛屿数量 又被称为 FloodFill 算法 class NumIslands:"""floodFill 算法https://leetcode.cn/problems/number-of-islands/"""def solution(self, grid: List[List[str]]) -> int:res 0m, n len(grid), len(grid[0])for i in range(m):for…...

JDBC学习汇总

概念 JDBC&#xff1a;JDBC是Java提供的一套用来操作数据库的接口 通过Java代码操作数据库 1.确定数据库是可以正常使用&#xff08;MySQL服务是否正常开启&#xff09; 2.确定MySQL的账号和密码是正确的 3.确定MySQL版本和MySQL驱动版本匹配 4.在工程&#xff08;module&#…...

HarmonyOS—UI开发性能提升的推荐方法

注&#xff1a;本文转载自HarmonyOS官网文档 开发者若使用低性能的代码实现功能场景可能不会影响应用的正常运行&#xff0c;但却会对应用的性能造成负面影响。本章节列举出了一些可提升性能的场景供开发者参考&#xff0c;以避免应用实现上带来的性能劣化。 使用数据懒加载 开…...

英文科技论文写作与发表-常见英语写作困扰(第3章)

1.常见英语写作困扰 英语写作应该是越精炼越好。写完一个句子&#xff0c;建议尝试删除某个或某些单词&#xff0c;如果删除后句子意义基本不变&#xff0c;就应该删除。 1.1 所有格 使用所有格可以省去至少一个单词&#xff08;of&#xff09;,如&#xff1a;Kangs book T…...

video标签自动播放音视频并绘制波形图

html中的<video>标签可以用来播放常见的音视频格式&#xff0c;支持的格式包括:MP3、Ogg、WAV、AAC、MP4、WebM、AVI等&#xff0c;当然支持的格式也和浏览器和操作系统有关。这里以一个可以自动播放音视频并绘制波形图的页面为例说明一下<video>标签的用法。 vid…...

Netty—EventLoop

文章目录 一、EventLoopGroup 是什么&#xff1f;&#x1f914;️二、NioEventLoop 有哪些重要组成部分&#xff1f;&#x1f50d;三、NioEventLoop 的 thread 在何时启动&#xff1f;三、 run() 方法中线程在干嘛&#xff1f; 一、EventLoopGroup 是什么&#xff1f;&#x1f…...

[极客大挑战 2019]FinalSQL(bypass盲注)

这里是数字型注入&#xff0c;选择一个序号 fuzz ?id1这里过滤了很多东西 使用fuzzSQL字典&#xff0c;这是我自己定义编写的一个fuzz字典&#xff0c;内容较少 select from information . tables whereand " or | & union columns updatexml extractvalue databa…...

如何实现小程序与h5页面间的跳转

接到新需求&#xff0c;要在小程序页面内点击按钮实现跳转h5&#xff0c;一开始没接触过&#xff0c;还挺头疼的&#xff0c;但真正做起来&#xff0c;也就那么一回事啦&#xff0c;废话少说&#xff0c;直接上 1. 配置域名 先登录小程序开发平台&#xff0c;将页面需要跳转的…...

企业架构LNMP学习笔记9

nginx配置文件定义php-fpm服务&#xff1a; 编写测试文件&#xff1a; vim /usr/local/nginx/html/index.php 内容&#xff1a; <?phpphpinfo(); 在nginx的配置文件中配置&#xff1a; 修改配置文件&#xff0c;告知nginx如果收到.php结尾的请求&#xff0c;交由给php-…...

华为OD机试 - 二维伞的雨滴效应(Java JS Python)

题目描述 普通的伞在二维平面世界中,左右两侧均有一条边,而两侧伞边最下面各有一个伞坠子,雨滴落到伞面,逐步流到伞坠处,会将伞坠的信息携带并落到地面,随着日积月累,地面会呈现伞坠的信息。 1、为了模拟伞状雨滴效应,用二叉树来模拟二维平面伞(如下图所示),现在输…...

【HttpRunnerManager】搭建接口自动化测试平台操作流程

一、需要准备的知识点 1. linux: 安装 python3、nginx 安装和配置、mysql 安装和配置 2. python: django 配置、uwsgi 配置 二、我搭建的环境 1. Centos7 &#xff08;配置 rabbitmq、mysql 、Supervisord&#xff09; 2. python 3.6.8 &#xff08;配置 django、uwsgi&am…...

【C++】STL-常用算法-常用查找算法

0.前言 1.find #include <iostream> using namespace std;// 常用查找算法 find #include<vector> #include<algorithm>//查找 内置数据类型 void test01() {vector<int>v;for (int i 0; i < 10; i){v.push_back(i);}//查找 容器中 是否有 5 这个元…...

vue3 webpack打包流程及安装 (1)

npm run build 也可以打包 如果没有特殊需求 可以使用 效果其实是差不多的 --------------------------------------------------------------------------------------------------------------------------------- webpack网址 &#xff1a; 起步 | webpack 中文文档 (docsc…...

【C++】内联函数 ① ( 内联函数引入 | 内联函数语法 )

文章目录 一、内联函数引入1、内联函数引入2、代码示例 - 宏代码片段 与 内联函数 二、内联函数语法1、内联函数语法说明2、代码示例 - 内联函数基本语法 一、内联函数引入 1、内联函数引入 " 内联函数 " 是 C 语言中的一种特殊函数 , 其目的是为了提高程序的执行效率…...

聊聊springboot的ConfigurationProperties的绑定

序 本文主要研究一下springboot的ConfigurationProperties的绑定 ConfigurationPropertiesBindingPostProcessor org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java /*** {link BeanPostProcessor} to bind {link PropertySo…...

Mysql和Oracle的语法区别?

Mysql和Oracle是两种不同的关系型数据库。 MySQL通常在中小型应用程序、Web应用程序和小型企业中广泛使用&#xff0c;因为它易于学习和部署&#xff0c;而且成本较低。 Oracle数据库通常用于大型企业和复杂的企业级应用程序&#xff0c;因为它提供了高度可扩展性、高可用性…...

F - LIS on Tree

F - LIS on Tree (atcoder.jp) 问题描述&#xff1a;树上LIS。 普通LIS。O(n * n)。 void solve() {int n; cin>>n;vector<int> f(n 1),a(n1);for(int i 1; i < n; i) {cin>>a[i];f[i] 1;for(int j 1; j < i; j) {if(a[i] > a[j]) f[i] max…...

2023 年全国大学生数学建模B题目-多波束测线问题

B题目感觉属于平面几何和立体几何的问题&#xff0c;本质上需要推导几何变换情况&#xff0c;B题目属于有标准答案型&#xff0c;没太大的把握不建议选择&#xff0c;可发挥型不大。 第一问 比较简单&#xff0c;就一个2维平面的问题&#xff0c;但有点没理解&#xff0c;这个…...

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇&#xff0c;在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下&#xff1a; 【Note】&#xff1a;如果你已经完成安装等操作&#xff0c;可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作&#xff0c;重…...

RestClient

什么是RestClient RestClient 是 Elasticsearch 官方提供的 Java 低级 REST 客户端&#xff0c;它允许HTTP与Elasticsearch 集群通信&#xff0c;而无需处理 JSON 序列化/反序列化等底层细节。它是 Elasticsearch Java API 客户端的基础。 RestClient 主要特点 轻量级&#xff…...

web vue 项目 Docker化部署

Web 项目 Docker 化部署详细教程 目录 Web 项目 Docker 化部署概述Dockerfile 详解 构建阶段生产阶段 构建和运行 Docker 镜像 1. Web 项目 Docker 化部署概述 Docker 化部署的主要步骤分为以下几个阶段&#xff1a; 构建阶段&#xff08;Build Stage&#xff09;&#xff1a…...

React hook之useRef

React useRef 详解 useRef 是 React 提供的一个 Hook&#xff0c;用于在函数组件中创建可变的引用对象。它在 React 开发中有多种重要用途&#xff0c;下面我将全面详细地介绍它的特性和用法。 基本概念 1. 创建 ref const refContainer useRef(initialValue);initialValu…...

Redis相关知识总结(缓存雪崩,缓存穿透,缓存击穿,Redis实现分布式锁,如何保持数据库和缓存一致)

文章目录 1.什么是Redis&#xff1f;2.为什么要使用redis作为mysql的缓存&#xff1f;3.什么是缓存雪崩、缓存穿透、缓存击穿&#xff1f;3.1缓存雪崩3.1.1 大量缓存同时过期3.1.2 Redis宕机 3.2 缓存击穿3.3 缓存穿透3.4 总结 4. 数据库和缓存如何保持一致性5. Redis实现分布式…...

Golang dig框架与GraphQL的完美结合

将 Go 的 Dig 依赖注入框架与 GraphQL 结合使用&#xff0c;可以显著提升应用程序的可维护性、可测试性以及灵活性。 Dig 是一个强大的依赖注入容器&#xff0c;能够帮助开发者更好地管理复杂的依赖关系&#xff0c;而 GraphQL 则是一种用于 API 的查询语言&#xff0c;能够提…...

现代密码学 | 椭圆曲线密码学—附py代码

Elliptic Curve Cryptography 椭圆曲线密码学&#xff08;ECC&#xff09;是一种基于有限域上椭圆曲线数学特性的公钥加密技术。其核心原理涉及椭圆曲线的代数性质、离散对数问题以及有限域上的运算。 椭圆曲线密码学是多种数字签名算法的基础&#xff0c;例如椭圆曲线数字签…...

关于 WASM:1. WASM 基础原理

一、WASM 简介 1.1 WebAssembly 是什么&#xff1f; WebAssembly&#xff08;WASM&#xff09; 是一种能在现代浏览器中高效运行的二进制指令格式&#xff0c;它不是传统的编程语言&#xff0c;而是一种 低级字节码格式&#xff0c;可由高级语言&#xff08;如 C、C、Rust&am…...

招商蛇口 | 执笔CID,启幕低密生活新境

作为中国城市生长的力量&#xff0c;招商蛇口以“美好生活承载者”为使命&#xff0c;深耕全球111座城市&#xff0c;以央企担当匠造时代理想人居。从深圳湾的开拓基因到西安高新CID的战略落子&#xff0c;招商蛇口始终与城市发展同频共振&#xff0c;以建筑诠释对土地与生活的…...

Netty从入门到进阶(二)

二、Netty入门 1. 概述 1.1 Netty是什么 Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty是一个异步的、基于事件驱动的网络应用框架&#xff0c;用于…...