既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
}
// 判满。栈空返回1,否则返回0
int isFull(SqStack* stk)
{
return (stk->top - stk->base) == stk->stackCapacity ? 1 : 0;
}
// 返回栈中元素个数
int getSize(SqStack* stk)
{
return stk->top - stk->base;
}
// 入栈。入栈失败返回0,否则返回1
int push(SqStack* stk, dataType x)
{
if (isFull(stk)) {
//达到最大容量后,将新容量扩大为旧容量的 1.5 倍
int increment = stk->stackCapacity / 2;
stk->base = (dataType*)realloc(stk->base,
(stk->stackCapacity + increment) * sizeof(dataType));
if (!stk->base) {
return 0;
}
stk->top = stk->base + stk->stackCapacity;
stk->stackCapacity += increment;
}
\*stk->top++ = x;
return 1;
}
// 出栈。出栈失败返回0,否则返回1
int pop(SqStack* stk, dataType* x)
{
if (isEmpty(stk)) {
return 0;
} else {
*x = *–stk->top;
return 1;
}
}
// 取栈顶元素。成功取出返回1,否则返回0
int getTop(SqStack* stk, dataType* x)
{
if (isEmpty(stk)) {
return 0;
} else {
*x = *(stk->top - 1);
return 1;
}
}
// 清空栈
void clearSqStack(SqStack* stk)
{
stk->top = stk->base;
printf(“顺序栈已被清空!\n”);
}
// 销毁栈
void destroySqStack(SqStack* stk)
{
if (stk->base != NULL) {
free(stk->base);
}
printf(“栈已被销毁!\n”);
}
void traverseSqStack(SqStack stk)
{
int len = getSize(&stk);
if (len == 0) {
printf("栈为空!\n");
} else {
printf("遍历栈:");
int i;
for (i = 0; i < len; i++) {
printf("%d, ", \*(--stk.top));
}
printf("\n");
}
}
C:\Windows\system32\cmd.exe /c (gcc -fexec-charset=gbk cque.c -o cque && cque && del cque.exe)
入栈:
0 入栈,剩余元素个数为 1
1 入栈,剩余元素个数为 2
2 入栈,剩余元素个数为 3
3 入栈,剩余元素个数为 4
4 入栈,剩余元素个数为 5
5 入栈,剩余元素个数为 6
6 入栈,剩余元素个数为 7
7 入栈,剩余元素个数为 8
8 入栈,剩余元素个数为 9
9 入栈,剩余元素个数为 10
10 入栈,剩余元素个数为 11
11 入栈,剩余元素个数为 12
12 入栈,剩余元素个数为 13
13 入栈,剩余元素个数为 14
14 入栈,剩余元素个数为 15
15 入栈,剩余元素个数为 16
16 入栈,剩余元素个数为 17
17 入栈,剩余元素个数为 18
18 入栈,剩余元素个数为 19
19 入栈,剩余元素个数为 20
遍历栈:19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
栈中元素个数为:20
栈顶元素为:19
出栈:
19 出栈,剩余元素个数为 19
18 出栈,剩余元素个数为 18
17 出栈,剩余元素个数为 17
16 出栈,剩余元素个数为 16
15 出栈,剩余元素个数为 15
14 出栈,剩余元素个数为 14
13 出栈,剩余元素个数为 13
12 出栈,剩余元素个数为 12
11 出栈,剩余元素个数为 11
10 出栈,剩余元素个数为 10
9 出栈,剩余元素个数为 9
8 出栈,剩余元素个数为 8
7 出栈,剩余元素个数为 7
6 出栈,剩余元素个数为 6
5 出栈,剩余元素个数为 5
4 出栈,剩余元素个数为 4
3 出栈,剩余元素个数为 3
2 出栈,剩余元素个数为 2
1 出栈,剩余元素个数为 1
0 出栈,剩余元素个数为 0
栈为空!
栈已被销毁!
Hit any key to close this window…
## 2 链栈
实现:实质为单链表。指针top指向链表头部,插入元素从头部插入、删除元素从头部删除,从而实现后进先出
#include <stdio.h>
#include <stdlib.h>
typedef int dataType;
typedef struct node // 栈节点
{
dataType data;
struct node* next;
} StackNode;
typedef struct // 栈结构
{
StackNode* top; // 栈顶指针,指向栈顶元素
int size; // 栈中元素个数
} LinkedStack;
int initLinkedStack(LinkedStack* stk); // 创建空栈。创建成功返回1,否则返回0
int push(LinkedStack* stk, dataType x); // 入栈。入栈失败返回0,否则返回1
int pop(LinkedStack* stk, dataType* x); // 出栈。出栈失败返回0,否则返回1
int getTop(LinkedStack* stk, dataType* x); // 取栈顶元素。成功取出返回1,否则返回0
void destroyLinkedStack(LinkedStack* stk); // 销毁栈
void traverseLinkedStack(LinkedStack* stk); // 遍历栈中元素并输出
int main()
{
LinkedStack stk;
int i;
dataType x;
initLinkedStack(&stk);
printf("入栈:\n");
for (i = 0; i < 10; i++) {
push(&stk, i \* 10);
printf("%d 入栈,栈中剩余元素个数为 %d\n", i \* 10, stk.size);
}
traverseLinkedStack(&stk);
getTop(&stk, &x);
printf("栈顶元素为:%d\n", x);
int n = stk.size;
printf("出栈:\n");
for (i = 0; i < n; i++) {
pop(&stk, &x);
printf("%d 出栈,栈中剩余元素个数为 %d\n", x, stk.size);
}
traverseLinkedStack(&stk);
destroyLinkedStack(&stk);
return 0;
}
// 创建空栈。创建成功返回1,否则返回0
int initLinkedStack(LinkedStack* stk)
{
stk->top = NULL;
stk->size = 0;
return 1;
}
// 入栈。入栈失败返回0,否则返回1
int push(LinkedStack* stk, dataType x)
{
StackNode* node = (StackNode*)malloc(sizeof(StackNode));
if (node) {
node->data = x;
node->next = stk->top;
stk->top = node;
stk->size++;
return 1;
}
return 0;
}
// 出栈。出栈失败返回0,否则返回1
int pop(LinkedStack* stk, dataType* x)
{
if (stk->size != 0) {
StackNode* p = stk->top;
stk->top = p->next;
\*x = p->data;
free(p);
stk->size--;
return 1;
}
return 0;
}
// 取栈顶元素。成功取出返回1,否则返回0
int getTop(LinkedStack* stk, dataType* x)
{
if (stk->size != 0) {
*x = stk->top->data;
return 1;
}
return 0;
}
// 销毁栈
void destroyLinkedStack(LinkedStack* stk)
{
收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人
都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
朋友。**
[外链图片转存中…(img-L0X72StD-1715707779771)]
[外链图片转存中…(img-AzdeXzkx-1715707779773)]
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人
都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!