栈队列OJ练习题(C语言版)

目录

一、括号匹配问题

思路:

完整版C语言代码:  

讲解:

二、用队列实现栈

思路:

完整版C语言代码: 

讲解: 

三、用栈实现队列

思路:

完整版C语言代码:

讲解:

四、 设计循环队列

思路:

完整版C语言代码:

讲解:


如果栈和队列忘了,不妨看看小生的这两篇复习一下数据结构与算法—栈     数据结构与算法—队列

一、括号匹配问题

20. 有效的括号 - 力扣(LeetCode)

 

思路:

将左括号放入栈中,通过出栈与为入栈的符号进行比较。 

由于我们用C语言做这道题,所以代码前要加上咱们实现的的代码,同时要将数据类型STDataType改为char类型。

完整版C语言代码:  

typedef char STDataType;
typedef struct Stack
{
	STDataType* a;
	int top;
	int capacity;
}ST;

void STInit(ST* pst)
{
	assert(pst);
	pst->a = NULL;
	pst->top = 0;
	pst->capacity = 0;
}

void STDestroy(ST* pst)
{
	assert(pst);
	free(pst->a);
	pst->a = NULL;
	pst->top = 0;
	pst->capacity = 0;
}

void STPush(ST* pst,STDataType x)
{
	if (pst->top == pst->capacity) {
		int newCapacity = pst->capacity == 0 ? 4 :pst-> capacity * 2;
		STDataType* tmp = (STDataType*)realloc(pst->a, newCapacity * sizeof(STDataType));
		if (tmp == NULL) {
			perror("realloc fail");
			return;
		}
		pst->a = tmp;
		pst->capacity = newCapacity;
	}
	pst->a[pst->top] = x;
	pst->top++;
}

bool STEmpty(ST* pst)
{
	assert(pst);
	return pst->top == 0;
}

void STPop(ST* pst)
{
	assert(pst);
	assert(!STEmpty(pst));
	pst->top--;
}

STDataType STTop(ST* pst)
{
	assert(pst);
	assert(!STEmpty(pst));
	return pst->a[pst->top - 1];
}


int STSize(ST* pst)
{
	assert(pst);
	return pst->top;
}

//------以下为OJ提供-------

bool isValid(char* s) {
    ST st;
    STInit(&st);
    while (*s) {
        if (*s == '(' || *s == '[' || *s == '{') {
            STPush(&st, *s);
        }
        else {
            if (STEmpty(&st)) {
                STDestroy(&st);
                return false;
            }
            char top = STTop(&st);
            STPop(&st);
            if ((top != '(' && *s == ')') ||
                (top != '{' && *s == '}') ||
                (top != '[' && *s == ']')) {
                STDestroy(&st);
                return false;
            }
        }
        s++;
    }
    bool ret = STEmpty(&st);
    STDestroy(&st);
    return ret;
}

讲解:

isValid函数:

  • 创建栈结构体ST变量 st,然后进行初始化。
  • 以*s为循环进行条件
  • 首先,创建一个名为 st 的 ST 结构体实例,并使用 STInit 初始化它。

  • 然后,遍历输入字符串 s 中的每个字符。
  • 对于每个字符,如果是左括号 '(','[','{' ,则将其推入栈中。
  • 如果是右括号 ')',']','}' ,则执行以下操作:

检查栈是否为空,如果为空,表示没有对应的左括号,则销毁栈,返回 false

否则,弹出栈顶元素,将其与当前右括号进行匹配。如果不匹配,则销毁栈,返回 false

  • 最后,遍历完整个字符串后,检查栈是否为空。如果栈为空,表示所有括号都成功匹配,返回 true,否则返回 false
  • 最后,调用 STDestroy 销毁栈,并返回最终的匹配结果。

二、用队列实现栈

225. 用队列实现栈 - 力扣(LeetCode)

 

思路:

 准备两个队列,第一个队列依次出队到只剩一个数据时停止,将已出队的数据依次入队到第二个队列,将第一个队列仅剩的一个数据出队即实现了栈的出栈。入栈时哪个队列不为空则在哪个队列入队。

由于我们用C语言做这道题,所以代码前要加上咱们实现的队列的代码。

完整版C语言代码: 

typedef int QDataType;
typedef struct QueueNode
{
    struct QueueNode* next;
    QDataType data;
}QNode;

typedef struct Queue
{
    QNode* phead;
    QNode* ptail;
    int size;
}Queue;

void QueueInit(Queue* pq)
{
    assert(pq);
    pq->phead = NULL;
    pq->ptail = NULL;
    pq->size = 0;
}
void QueueDestroy(Queue* pq)
{
    assert(pq);
    QNode* cur = pq->phead;
    while (cur) {
        QNode* next = cur->next;
        free(cur);
        cur = next;
    }
    pq->phead = pq->ptail = NULL;
    pq->size = 0;
}
void QueuePush(Queue* pq, QDataType x)
{
    assert(pq);
    QNode* newnode = (QNode*)malloc(sizeof(QNode));
    if (newnode == NULL) {
        perror("mallloc fail\n");
        return;
    }
    newnode->data = x;
    newnode->next = NULL;
    if (pq->ptail == NULL) {
        assert(pq->phead == NULL);
        pq->phead = pq->ptail = newnode;
    }
    else {
        pq->ptail->next = newnode;
        pq->ptail = newnode;
    }
    pq->size++;
}
bool QueueEmpty(Queue* pq)
{
    assert(pq);
    return pq->size == 0;
}
void QueuePop(Queue* pq)
{
    assert(pq);
    assert(!QueueEmpty(pq));
    if (pq->phead->next == NULL) {
        free(pq->phead);
        pq->phead = pq->ptail = NULL;
    }
    else {
        QNode* next = pq->phead->next;
        free(pq->phead);
        pq->phead = next;
    }
    pq->size--;
}
QDataType QueueFront(Queue* pq)
{
    assert(pq);
    assert(!QueueEmpty(pq));
    return pq->phead->data;
}
QDataType QueueBack(Queue* pq)
{
    assert(pq);
    assert(!QueueEmpty(pq));
    return pq->ptail->data;
}
int QueueSize(Queue* pq)
{
    assert(pq);
    return pq->size;
}

//------以下为OJ提供-------

typedef struct {
    Queue q1;
    Queue q2;
} MyStack;

MyStack* myStackCreate() {
    MyStack* obj = (MyStack*)malloc(sizeof(MyStack));
    if (obj == NULL) {
        perror("malloc fail");
        return NULL;
    }
    QueueInit(&obj->q1);
    QueueInit(&obj->q2);
    return obj;
}

void myStackPush(MyStack* obj, int x) {
    if (!QueueEmpty(&obj->q1)) {
        QueuePush(&obj->q1, x);
    }
    else {
        QueuePush(&obj->q2, x);
    }
}

int myStackPop(MyStack* obj) {
    Queue* pEmptyQ = &obj->q1;
    Queue* pNonEmptyQ = &obj->q2;
    if (!QueueEmpty(&obj->q1)) {
        pEmptyQ = &obj->q2;
        pNonEmptyQ = &obj->q1;
    }
    while (QueueSize(pNonEmptyQ) > 1) {
        QueuePush(pEmptyQ, QueueFront(pNonEmptyQ));
        QueuePop(pNonEmptyQ);
    }
    int top = QueueFront(pNonEmptyQ);
    QueuePop(pNonEmptyQ);
    return top;
}

int myStackTop(MyStack* obj) {
    if (!QueueEmpty(&obj->q1)) {
        return QueueBack(&obj->q1);
    }
    else {
        return QueueBack(&obj->q2);
    }
}

bool myStackEmpty(MyStack* obj) {
    return QueueEmpty(&obj->q1) &&
        QueueEmpty(&obj->q2);
}

void myStackFree(MyStack* obj) {
    QueueDestroy(&obj->q1);
    QueueDestroy(&obj->q2);
    free(obj);
}

讲解: 

 1、

typedef struct {
    Queue q1;
    Queue q2;
} MyStack;

首先在匿名结构体MyStack中设置两个成员 q1、q2,他们的类型为结构体Queue。

2、

MyStack* myStackCreate() {
    MyStack* obj = (MyStack*)malloc(sizeof(MyStack));
    if (obj == NULL) {
        perror("malloc fail");
        return NULL;
    }
    QueueInit(&obj->q1);
    QueueInit(&obj->q2);
    return obj;
}

myStackCreate中首先创建结构体 MyStack 指针 obj,并为其开辟空间,开辟失败则打印错误信息,然后对 obj 的两个成员 (队列) 进行初始化。

3、

void myStackPush(MyStack* obj, int x) {
    if (!QueueEmpty(&obj->q1)) {
        QueuePush(&obj->q1, x);
    }
    else {
        QueuePush(&obj->q2, x);
    }
}

myStackPush中首先判断哪个队列不为空,对不为空的队列进行入队(入栈)。

4、

int myStackPop(MyStack* obj) {
    Queue* pEmptyQ = &obj->q1;
    Queue* pNonEmptyQ = &obj->q2;
    if (!QueueEmpty(&obj->q1)) {
        pEmptyQ = &obj->q2;
        pNonEmptyQ = &obj->q1;
    }
    while (QueueSize(pNonEmptyQ) > 1) {
        QueuePush(pEmptyQ, QueueFront(pNonEmptyQ));
        QueuePop(pNonEmptyQ);
    }
    int top = QueueFront(pNonEmptyQ);
    QueuePop(pNonEmptyQ);
    return top;
}
  • myStackPop中首先要找到为“空”和“不为空”的队列,假设队列q1为空,q2不为空,通过QueueEmpty判断如果q1为空则假设不变,否则二者互换。
  • 然后将不为空的队列的数据依次入队到为空的队列,入队结束后将不为空的队列进行出队,进行下一次循环,直到不为空的队列只剩一个元素停止循环。
  • 调用QueueFront函数获取队头节点赋值给变量top,将不为空队列仅剩的数据出队。
  • 返回top。

5、

int myStackTop(MyStack* obj) {
    if (!QueueEmpty(&obj->q1)) {
        return QueueBack(&obj->q1);
    }
    else {
        return QueueBack(&obj->q2);
    }
}

myStackTop函数找出不为空的队列,对不为空的队列调用QueueBack返回栈顶元素。

6、

bool myStackEmpty(MyStack* obj) {
    return QueueEmpty(&obj->q1) &&
        QueueEmpty(&obj->q2);
}

myStackEmpty调用QueueEmpty判断两个队列是否为空即为判断栈是否为空。

7、

void myStackFree(MyStack* obj) {
    QueueDestroy(&obj->q1);
    QueueDestroy(&obj->q2);
    free(obj);
}

myStackFree调用 QueueDestroy释放两个队列的内存空间,最后释放栈 obj 的内存空间。

三、用栈实现队列

232. 用栈实现队列 - 力扣(LeetCode)

思路:

一个栈用于入队,一个栈用于出队。出队栈不为空则从入队栈依次出栈,然后入栈到出队栈,这时原本入队栈的数据在出队栈中直接出栈,即可实现队列的先进先出,再次入队时数据进入入队栈,等待出队栈为空时再将数据倒过来。

 

 由于我们用C语言做这道题,所以代码前要加上咱们实现的的代码。

完整版C语言代码:

typedef int STDataType;
typedef struct Stack
{
	STDataType* a;
	int top;
	int capacity;
}ST;

void STInit(ST* pst)
{
	assert(pst);
	pst->a = NULL;
	pst->top = 0;
	pst->capacity = 0;
}

void STDestroy(ST* pst)
{
	assert(pst);
	free(pst->a);
	pst->a = NULL;
	pst->top = 0;
	pst->capacity = 0;
}

void STPush(ST* pst, STDataType x)
{
	if (pst->top == pst->capacity) {
		int newCapacity = pst->capacity == 0 ? 4 : pst->capacity * 2;
		STDataType* tmp = (STDataType*)realloc(pst->a, newCapacity * sizeof(STDataType));
		if (tmp == NULL) {
			perror("realloc fail");
			return;
		}
		pst->a = tmp;
		pst->capacity = newCapacity;
	}
	pst->a[pst->top] = x;
	pst->top++;
}

bool STEmpty(ST* pst)
{
	assert(pst);
	return pst->top == 0;
}

void STPop(ST* pst)
{
	assert(pst);
	assert(!STEmpty(pst));
	pst->top--;
}

STDataType STTop(ST* pst)
{
	assert(pst);
	assert(!STEmpty(pst));
	return pst->a[pst->top - 1];
}

int STSize(ST* pst)
{
	assert(pst);
	return pst->top;
}

//------以下为OJ提供-------

typedef struct {
	ST pushst;
	ST popst;
} MyQueue;

MyQueue* myQueueCreate() {
	MyQueue* obj = (MyQueue*)malloc(sizeof(MyQueue));
	if (obj == NULL) {
		perror("malloc fail");
		return 0;
	}
	STInit(&obj->pushst);
	STInit(&obj->popst);
	return obj;
}

void myQueuePush(MyQueue* obj, int x) {
	STPush(&obj->pushst, x);
}

int myQueuePop(MyQueue* obj) {
	int front = myQueuePeek(obj);
	STPop(&obj->popst);
	return front;
}

int myQueuePeek(MyQueue* obj) {
	if (STEmpty(&obj->popst)) {
		while (!STEmpty(&obj->pushst)) {
			STPush(&obj->popst, STTop(&obj->pushst));
			STPop(&obj->pushst);
		}
	}
	return STTop(&obj->popst);
}

bool myQueueEmpty(MyQueue* obj) {
	return STEmpty(&obj->pushst) && STEmpty(&obj->popst);
}

void myQueueFree(MyQueue* obj) {
	STDestroy(&obj->pushst);
	STDestroy(&obj->popst);
	free(obj);
}

讲解:

1、

typedef struct {
	ST pushst;
	ST popst;
} MyQueue;

在MyQueue结构体中创建两个栈 pushst 和 popst。

2、

MyQueue* myQueueCreate() {
    MyQueue* obj = (MyQueue*)malloc(sizeof(MyQueue));
    if (obj == NULL) {
        perror("malloc fail");
        return 0;
    }
    STInit(&obj->pushst);
    STInit(&obj->popst);
    return obj;
}

创建一个 MyQueue 类型的队列 obj 。然后通过 malloc 申请内存,如果申请失败则调用perror打印错误信息,结束函数,然后分别初始化 pushst 和 popst 两个栈,返回队列obj。

 3、

void myQueuePush(MyQueue* obj, int x) {
    STPush(&obj->pushst, x);
}

将元素 x 入队。直接调用 STPush 函数将元素 x 压入 pushst 栈。

 4、

int myQueuePop(MyQueue* obj) {
    int front = myQueuePeek(obj);
    STPop(&obj->popst);
    return front;
}

这个函数用于将队首元素出队,并返回其值。首先调用 myQueuePeek 函数获取队首元素的值,然后调用 STPop 函数将元素从 popst 栈中弹出。

5、 

int myQueuePeek(MyQueue* obj) {
    if (STEmpty(&obj->popst)) {
        while (!STEmpty(&obj->pushst)) {
            STPush(&obj->popst, STTop(&obj->pushst));
            STPop(&obj->pushst);
        }
    }
    return STTop(&obj->popst);
}

这个函数用于获取队首元素的值。首先判断 popst 栈是否为空,如果为空则将 pushst 栈中的所有元素依次弹出并压入 popst 栈,最后通过 STTop 函数获取 popst 栈顶元素的值。

6、

bool myQueueEmpty(MyQueue* obj) {
    return STEmpty(&obj->pushst) && STEmpty(&obj->popst);
}

 这个函数用于判断队列是否为空。只有当 pushst 和 popst 两个栈都为空时,队列才为空。

7、 

void myQueueFree(MyQueue* obj) {
    STDestroy(&obj->pushst);
    STDestroy(&obj->popst);
    free(obj);
}

这个函数用于释放 MyQueue 类型队列所占用的内存空间。

首先调用 STDestroy 函数销毁 pushst 和 popst 两个栈,然后调用 free 函数释放 obj 所占用的内存空间。

四、 设计循环队列

622. 设计循环队列

 思路:

选择数组作为循环队列,为了避免队列为空和队列为满时 front 和 rear 相同的情况,将数组的容量设置为比题中要求的队列长度大一(即实际容量为k+1)。

完整版C语言代码:

typedef struct {
    int front;
    int rear;
    int k;
    int* a;
} MyCircularQueue;

MyCircularQueue* myCircularQueueCreate(int k) {
    MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    obj->a = (int*)malloc((k + 1) * sizeof(int));
    obj->k = k;
    obj->front = obj->rear = 0;
    return obj;
}

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    return obj->front == obj->rear;
}

bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return (obj->rear + 1) % (obj->k + 1) == obj->front;
}

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if (myCircularQueueIsFull(obj)) {
        return false;
    }
    obj->a[obj->rear] = value;
    obj->rear++;
    obj->rear %= (obj->k + 1);
    return true;
}

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return false;
    }
    obj->front++;
    obj->front %= (obj->k + 1);
    return true;
}

int myCircularQueueFront(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->a[obj->front];
}

int myCircularQueueRear(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->a[(obj->rear + obj->k) % (obj->k + 1)];
}

void myCircularQueueFree(MyCircularQueue* obj) {
    free(obj->a);
    free(obj);
}

讲解:

1、

typedef struct {
    int front;
    int rear;
    int k;
    int* a;
} MyCircularQueue;

定义MyCircularQueue结构体,front指向队列第一个元素,rear指向队列最后一个元素的下一个位置,k为队列容量,指针a用于动态分配数组存储队列元素。

2、 

MyCircularQueue* myCircularQueueCreate(int k) {
    MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    obj->a = (int*)malloc((k + 1) * sizeof(int));
    obj->k = k;
    obj->front = obj->rear = 0;
    return obj;
}

对队列obj开辟空间,为数组a分配k+1个整型元素大小的空间,多出来的一个空间用于区分空队列和满队列,将k的值存储在队列obj中,初始化 front 和 rear 为 0。

这里将检查队列是否为空或已满的函数从后面移动到这里,方便后续函数能正常调用。 

3、

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    return obj->front == obj->rear;
}

如果front与rear重合,则队列为空。

4、

bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return (obj->rear + 1) % (obj->k + 1) == obj->front;
}

通过 (obj->rear + 1) % (obj->k + 1) 计算下一个元素将要插入的位置,如果这个位置和 front 相同,说明队列已满。

5、

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if (myCircularQueueIsFull(obj)) {
        return false;
    }
    obj->a[obj->rear] = value;
    obj->rear++;
    obj->rear %= (obj->k + 1);
    return true;
}

首先检查队列是否已满。

  • 如果满了,返回 false;不满则将数据放入数组的rear位置,然后rear向后移动一位。
  • 如果rear移动到最后一个元素的后一项位置,则通过 obj->rear %= (obj->k + 1); 更新rear的位置。

6、 

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return false;
    }
    obj->front++;
    obj->front %= (obj->k + 1);
    return true;
}
  • 首先检查队列是否为空。如果为空,返回 false,
  • 如果不空,更新 front 的值,表示已经移除了一个元素,返回 true。

7、 

int myCircularQueueFront(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->a[obj->front];
}
  • 如果队列为空,返回 -1。
  • 如果不空,返回 front 指向的元素。

8、 

int myCircularQueueRear(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->a[(obj->rear + obj->k) % (obj->k + 1)];
}
  • 如果队列为空,返回 -1。
  • 如果不空,返回 rear 指向的前一个元素。

 9、

void myCircularQueueFree(MyCircularQueue* obj) {
    free(obj->a);
    free(obj);
}

释放队列数组 a 和队列结构体的内存空间。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/109509.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

任正非说:扩张必须踩在坚实的基础上,擅自扩张只能是自杀。

嗨,你好!这是华研荟【任正非说】系列的第23篇文章,让我们继续聆听任正非先生的真知灼见,学习华为的管理思想和管理理念。 一、要想赢,要么在剑法上高于人,要么在盾牌上坚于人。若果剑不如人,就要…

虚拟机上的linux centos7无法连接ssh

1、排查有没有安装 openssh-server,在终端中输入 yum list installed | grep openssh-server此处显示已经安装了 openssh-server,如果又没任何输出显示表示没有安装 openssh-server,通过输入 yum install openssh-server进行安装 2、找到了…

Selenium3-当元素通过@FindBy获取时,返回元素为null

报错: 在获取元素的js属性时一直获取不到,报空指针,定位到元素时,发现是FindBy的元素没有找到 解决方法: 在page类的构造函数中加上了 界面初始化,让元素先隐式加载,这样就不会出现返回元素为空的情况辣 PageFactory…

15. 机器学习 - 支持向量机

Hi, 你好。我是茶桁。 逻辑回归预测心脏病 在本节课开始呢,我给大家一份逻辑回归的练习,利用下面这个数据集做了一次逻辑回归预测心脏病的练习。 本次练习的代码在「茶桁的AI秘籍」在Github上的代码库内,数据集的获取在文末。这样做是因为我…

pytorch深度学习实践(一):线性模型y=w*x和y=w*x+b的代码和绘图实现

目录 题目描述1. yw*x2. yw*xb 代码第一题: y w*x第二题:y wxb 绘图工具 学习视频: 刘二大人pytorch1-线性模型 题目描述 1. yw*x 使用线性模型y w*x计算模型的损失值并且使用matplotlib给出cost function图像。 2. yw*xb 使用线性模型y w*xb给出cost funct…

计算机网络基础三

课程目标 理解路由表的作用 能够读懂路由表信息 能够使用图形抓包工具 wireshark 进行数据包的抓取 ,如( TCP/IP 的三次握手四次断开) 一、路由表 思考: 什么是交换,什么是路由,什么是路由表?1. 交换是指同网络访…

外卖跑腿小程序开发如何满足不断变化的用户需求?

外卖跑腿小程序市场竞争激烈,用户需求不断演变。为了保持竞争力,开发团队需要不断适应变化,提供新功能和改进用户体验。本文将讨论如何通过技术手段来满足不断变化的用户需求。 1. 灵活的后端服务 后端服务是外卖跑腿小程序的核心&#xf…

如何优雅地单元测试 Kotlin/Java 中的 private 方法?

翻译自 https://medium.com/mindorks/how-to-unit-test-private-methods-in-java-and-kotlin-d3cae49dccd ❓如何单元测试 Kotlin/Java 中的 private 方法❓ 首先,开发者应该测试代码里的 private 私有方法吗? 直接信任这些私有方法,测试到…

css画一条虚线,用到background-image:linear-gradient线性渐变的属性

CSS实现虚线的方法_css 虚线_saltlike的博客-CSDN博客 渐变属性(background-image)全解析_background-image linear_大聪明码农徐的博客-CSDN博客 Background:linear-gradient()详解_background: linear-gradient_小白白中之白的博客-CSDN博客 注意: 必须要写高…

最短路径:迪杰斯特拉算法

简介 英文名Dijkstra 作用&#xff1a;找到路中指定起点到指定终点的带权最短路径 核心步骤 1&#xff09;确定起点&#xff0c;终点 2&#xff09;从未走过的点中选取从起点到权值最小点作为中心点 3&#xff09;如果满足 起点到中心点权值 中心点到指定其他点的权值 < 起…

C++进阶语法——智能指针【学习笔记(五)】

文章目录 1、智能指针简介1.1 原始指针&#xff08;raw pointer&#xff09;的⼀些问题1.2 智能指针&#xff08;smart pointers&#xff09; 2、智能指针&#xff08;smart pointers&#xff09;——unique_ptr2.1 unique_ptr 的声明2.2 unique_ptr 的函数2.3 ⾃定义类型使⽤ …

基于深度学习的中文情感分类 - 卷积神经网络 情感分类 情感分析 情感识别 评论情感分类 计算机竞赛

文章目录 1 前言2 情感文本分类2.1 参考论文2.2 输入层2.3 第一层卷积层&#xff1a;2.4 池化层&#xff1a;2.5 全连接softmax层&#xff1a;2.6 训练方案 3 实现3.1 sentence部分3.2 filters部分3.3 featuremaps部分3.4 1max部分3.5 concat1max部分3.6 关键代码 4 实现效果4.…

【HTML/CSS学习】margin和padding的区别

1. margin margin&#xff08;外边距&#xff09;属性定义元素周围的空间。 margin主要在元素的外部创建空白区域&#xff0c;用于分隔元素与其相邻元素之间的距离。 用处&#xff1a;可以用于调整两个元素之间的间隔。 2. padding padding&#xff08;填充&#xff09;定义…

IDE的组成

集成开发环境&#xff08;IDE&#xff0c;Integrated Development Environment &#xff09;是用于提供程序开发环境的应用程序&#xff0c;一般包括代码编辑器、编译器、调试器和图形用户界面等工具。集成了代码编写功能、分析功能、编译功能、调试功能等一体化的开发软件服务…

拿下国家级信创认证 中科驭数KPU SWIFT-2200N成为国内首款满足金融业严苛要求的DPU产品

近日&#xff0c;中科驭数KPU SWIFT-2200N低时延DPU卡&#xff0c;在中国人民银行旗下金融信创生态实验室完成测试并取得测试报告&#xff0c;这意味着中科驭数低时延网络代表性产品的应用领域从证券进一步拓展到了银行业&#xff0c;成为国内首款满足金融行业严苛要求的DPU产品…

iis前端代理后台tomcat

1)tomcat服务器配置运行好&#xff0c;服务地址位于 localhost:8080/wechat 2)iis 绑定了域名 api.abc.com 希望访问 api.abc.com/wechat时&#xff0c;实际由tomcat的服务处理; 3)iis上需要添加组件 requestRouter_amd64.msi rewrite_amd64_zh-CN.msi 4)iis进行相关配置…

记录linux运行服务提示报错/bin/java: 没有那个文件或目录

描述&#xff1a;在执行jar启动命令时候提示 没有/bin/java 这个文件或者目录&#xff1b;然后我vi /usr/bin/java&#xff0c;是存在该文件的&#xff1b;那到底是什么问题呢&#xff0c;该不是没有创建软连接吧&#xff1f; 1、执行下述命令先测试下软链接是否有创建 ln -s …

用软件模拟IPC的RTSP流,对接烟火识别算法服务,做实时的烟火检测、人员入侵检测、抽烟检测等算法

最近在研发烟火识别的算法&#xff0c;想要检验算法集成到视频分析服务之后的效果&#xff0c;发现线上的摄像机很难发现火情&#xff0c;有的很长时间都不会有检测的结果&#xff0c;于是我就需要用已经被检验过的视频文件&#xff0c;模拟一路IPC的RTSP流&#xff0c;来测试烟…

jenkins如何安装?

docker pull jenkins/jenkins:lts-centos7-jdk8 2.docker-compose.yml version: 3 services:jenkins:image: jenkins/jenkins:lts-centos7-jdk8container_name: my-jenkinsports:- "8080:8080" # 映射 Jenkins Web 界面端口volumes:- jenkins_home:/var/jenkins_h…

【MySQL数据库】初识MySQL数据库、安装MySQL

文章目录 前言一、什么是 MySQL&#xff1f;二、MySQL 的强大之处三、Ubuntu安装MySQL步骤 1: 更新包列表步骤 2: 安装 MySQL步骤 3: 启动 MySQL 服务步骤 4: 验证 MySQL 安装步骤 5: 确保 MySQL 安全性 总结 前言 在今天的数字化世界中&#xff0c;数据是企业和个人的重要资产…
最新文章