当前位置: 首页 > 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;这个…...

网络编程(Modbus进阶)

思维导图 Modbus RTU&#xff08;先学一点理论&#xff09; 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议&#xff0c;由 Modicon 公司&#xff08;现施耐德电气&#xff09;于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…...

椭圆曲线密码学(ECC)

一、ECC算法概述 椭圆曲线密码学&#xff08;Elliptic Curve Cryptography&#xff09;是基于椭圆曲线数学理论的公钥密码系统&#xff0c;由Neal Koblitz和Victor Miller在1985年独立提出。相比RSA&#xff0c;ECC在相同安全强度下密钥更短&#xff08;256位ECC ≈ 3072位RSA…...

.Net框架,除了EF还有很多很多......

文章目录 1. 引言2. Dapper2.1 概述与设计原理2.2 核心功能与代码示例基本查询多映射查询存储过程调用 2.3 性能优化原理2.4 适用场景 3. NHibernate3.1 概述与架构设计3.2 映射配置示例Fluent映射XML映射 3.3 查询示例HQL查询Criteria APILINQ提供程序 3.4 高级特性3.5 适用场…...

8k长序列建模,蛋白质语言模型Prot42仅利用目标蛋白序列即可生成高亲和力结合剂

蛋白质结合剂&#xff08;如抗体、抑制肽&#xff09;在疾病诊断、成像分析及靶向药物递送等关键场景中发挥着不可替代的作用。传统上&#xff0c;高特异性蛋白质结合剂的开发高度依赖噬菌体展示、定向进化等实验技术&#xff0c;但这类方法普遍面临资源消耗巨大、研发周期冗长…...

DAY 47

三、通道注意力 3.1 通道注意力的定义 # 新增&#xff1a;通道注意力模块&#xff08;SE模块&#xff09; class ChannelAttention(nn.Module):"""通道注意力模块(Squeeze-and-Excitation)"""def __init__(self, in_channels, reduction_rat…...

Leetcode 3577. Count the Number of Computer Unlocking Permutations

Leetcode 3577. Count the Number of Computer Unlocking Permutations 1. 解题思路2. 代码实现 题目链接&#xff1a;3577. Count the Number of Computer Unlocking Permutations 1. 解题思路 这一题其实就是一个脑筋急转弯&#xff0c;要想要能够将所有的电脑解锁&#x…...

【Web 进阶篇】优雅的接口设计:统一响应、全局异常处理与参数校验

系列回顾&#xff1a; 在上一篇中&#xff0c;我们成功地为应用集成了数据库&#xff0c;并使用 Spring Data JPA 实现了基本的 CRUD API。我们的应用现在能“记忆”数据了&#xff01;但是&#xff0c;如果你仔细审视那些 API&#xff0c;会发现它们还很“粗糙”&#xff1a;有…...

NLP学习路线图(二十三):长短期记忆网络(LSTM)

在自然语言处理(NLP)领域,我们时刻面临着处理序列数据的核心挑战。无论是理解句子的结构、分析文本的情感,还是实现语言的翻译,都需要模型能够捕捉词语之间依时序产生的复杂依赖关系。传统的神经网络结构在处理这种序列依赖时显得力不从心,而循环神经网络(RNN) 曾被视为…...

深度学习习题2

1.如果增加神经网络的宽度&#xff0c;精确度会增加到一个特定阈值后&#xff0c;便开始降低。造成这一现象的可能原因是什么&#xff1f; A、即使增加卷积核的数量&#xff0c;只有少部分的核会被用作预测 B、当卷积核数量增加时&#xff0c;神经网络的预测能力会降低 C、当卷…...

React---day11

14.4 react-redux第三方库 提供connect、thunk之类的函数 以获取一个banner数据为例子 store&#xff1a; 我们在使用异步的时候理应是要使用中间件的&#xff0c;但是configureStore 已经自动集成了 redux-thunk&#xff0c;注意action里面要返回函数 import { configureS…...