纯C语言完整代码操作单链表(初始化、插入、删除、查找...)-程序员宅基地

技术标签: 算法  C语言  c语言  链表  数据结构  

本文旨在将王道书本上的算法思想用C语言实现,因为王道的书本上的代码有C++语法,所以照搬王道书上的代码不能准确运行。

采用头插法创建单链表完整代码

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
LinkList Head_ListInsert(LinkList L){
    
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
}

int main(){
    
    LinkList L;
    InitList(L);
    LinkList *p = Head_ListInsert(L);

    Print(p);
    return 0;
}

运行结果:在这里插入图片描述
头插法很明显输出顺序是反的,所以考虑尾插法

采用尾插法创建单链表完整代码

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}
//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
}

int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    Print(l);
    return 0;
}

运行结果图:
在这里插入图片描述
按序号、按值查找节点
需要注意序号是从1开始

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
    printf("\n");
}
//按序号查找节点
LNode *GetElem(LinkList L,int i){
    
    if(i<1){
    
        printf("输入的位序不合法!\n");
        return NULL;
    }
    int j=1;
    LNode *p = L->next;
    while(p!=NULL&&j<i){
    
        p = p->next;
        j++;
    }
    return p;
}
//按值查找
LNode *GetElemByValue(LinkList L,int value){
    
    LNode *p = L->next;
    int i=1;
    while(p!=NULL&&p->data!=value){
    
        p=p->next;
        i++;
    }
    printf("该值所处的位序位%d\n",i);
    return p;
}
int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    Print(l);
    LNode *ele = GetElem(l,4);
    printf("按位序查找的值位:%d\n",ele->data);
    LNode *elem = GetElemByValue(l,7);
    printf("按值查找的元素为:%d\n",elem->data);
    return 0;
}

运行结果:
在这里插入图片描述

按照位序插入和给定值插入

  • 按照位序插入
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdbool.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
    printf("\n");
}
//按序号查找节点
LNode *GetElem(LinkList L,int i){
    
    if(i<1){
    
        printf("输入的位序不合法!\n");
        return NULL;
    }
    int j=1;
    LNode *p = L->next;
    while(p!=NULL&&j<i){
    
        p = p->next;
        j++;
    }
    return p;
}
//按值查找
/*LNode *GetElemByValue(LinkList L,int value){
    LNode *p = L->next;
    int i=1;
    while(p!=NULL&&p->data!=value){
        p=p->next;
        i++;
    }
    printf("该值所处的位序位%d\n",i);
    return p;
}*/
//按位序插入值
bool InsertByLocation(LinkList L,int i,int e){
    
    if(i<1){
    
        printf("待插入的位置不合法!\n");
        return false;
    }
    LNode * proNode = GetElem(L,i-1);
    LNode *s = (LNode *)malloc(sizeof(LNode));
    s->data = e;
    s->next = proNode->next;
    proNode->next = s;
    return true;
}
int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    InsertByLocation(l,4,88);
    Print(l);
    LNode *ele = GetElem(l,4);
    //printf("按位序查找的值位:%d\n",ele->data);
    //LNode *elem = GetElemByValue(l,7);
    //printf("按值查找的元素为:%d\n",elem->data);

    return 0;
}

运行:在这里插入图片描述

对于给定值的插入有两种,分别为给定值的前插和后插操作
对于前插操作,需要先找到第i-1个节点再插入,时间复杂度为O(n),但是后插时间复杂度仅为O(1),更快更强

  • 前插
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdbool.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
    printf("\n");
}
//按序号查找节点
LNode *GetElem(LinkList L,int i){
    
    if(i<1){
    
        printf("输入的位序不合法!\n");
        return NULL;
    }
    int j=1;
    LNode *p = L->next;
    while(p!=NULL&&j<i){
    
        p = p->next;
        j++;
    }
    return p;
}
//按值查找
/*LNode *GetElemByValue(LinkList L,int value){
    LNode *p = L->next;
    int i=1;
    while(p!=NULL&&p->data!=value){
        p=p->next;
        i++;
    }
    printf("该值所处的位序位%d\n",i);
    return p;
}*/
//按位序插入值
bool InsertByLocation(LinkList L,int i,int e){
    
    if(i<1){
    
        printf("待插入的位置不合法!\n");
        return false;
    }
    LNode * proNode = GetElem(L,i-1);
    LNode *s = (LNode *)malloc(sizeof(LNode));
    s->data = e;
    s->next = proNode->next;
    proNode->next = s;
    return true;
}
//在给定值进行前插操作
bool InsertProNode(LNode *p,int e){
    
    if(p==NULL){
    
        return false;
    }
    LNode *s = (LNode *)malloc(sizeof(LNode));
    if(s==NULL){
    
        return false;
    }
    s->next = p->next;
    p->next = s;
    s->data = p->data;
    p->data = e;
    return true;
}

int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    //InsertByLocation(l,4,88);
    printf("未插入前的链表数据为:\n");
    Print(l);
    LNode * pri = GetElem(l,4);
    InsertProNode(pri,66);
    printf("执行插入操作之后链表的数据为:\n");
    Print(l);
    //LNode *ele = GetElem(l,4);
    //printf("按位序查找的值位:%d\n",ele->data);
    //LNode *elem = GetElemByValue(l,7);
    //printf("按值查找的元素为:%d\n",elem->data);

    return 0;
}

运行:在这里插入图片描述

  • 后插
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdbool.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
    printf("\n");
}
//按序号查找节点
LNode *GetElem(LinkList L,int i){
    
    if(i<1){
    
        printf("输入的位序不合法!\n");
        return NULL;
    }
    int j=1;
    LNode *p = L->next;
    while(p!=NULL&&j<i){
    
        p = p->next;
        j++;
    }
    return p;
}
//按值查找
/*LNode *GetElemByValue(LinkList L,int value){
    LNode *p = L->next;
    int i=1;
    while(p!=NULL&&p->data!=value){
        p=p->next;
        i++;
    }
    printf("该值所处的位序位%d\n",i);
    return p;
}*/
//按位序插入值
bool InsertByLocation(LinkList L,int i,int e){
    
    if(i<1){
    
        printf("待插入的位置不合法!\n");
        return false;
    }
    LNode * proNode = GetElem(L,i-1);
    LNode *s = (LNode *)malloc(sizeof(LNode));
    s->data = e;
    s->next = proNode->next;
    proNode->next = s;
    return true;
}
//在给定值进行前插操作
bool InsertProNode(LNode *p,int e){
    
    if(p==NULL){
    
        return false;
    }
    LNode *s = (LNode *)malloc(sizeof(LNode));
    if(s==NULL){
    
        return false;
    }
    s->next = p->next;
    p->next = s;
    s->data = p->data;
    p->data = e;
    return true;
}
//在给定节点执行后插操作
bool InsertNextNode(LNode *p,int e){
    
    if(p==NULL){
    
        return false;
    }
    LNode *s = (LNode *)malloc(sizeof(LNode));
    if(s==NULL){
    
        return false;
    }
    s->data = e;
    s->next = p->next;
    p->next = s;
    return true;
}

int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    //InsertByLocation(l,4,88);
    printf("未插入前的链表数据为:\n");
    Print(l);
    LNode * pri = GetElem(l,4);
    //InsertProNode(pri,66);
    InsertNextNode(pri,55);
    printf("执行插入操作之后链表的数据为:\n");
    Print(l);
    //LNode *ele = GetElem(l,4);
    //printf("按位序查找的值位:%d\n",ele->data);
    //LNode *elem = GetElemByValue(l,7);
    //printf("按值查找的元素为:%d\n",elem->data);

    return 0;
}

运行结果:
在这里插入图片描述

删除指定的节点

此算法的复杂度为O(1)

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdbool.h>

typedef struct LNode{
    
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化单链表
LinkList InitList(LinkList L){
    
    L=(LinkList)malloc(sizeof(LNode));
    L->next = NULL;
    printf("单链表的初始化创建成功!\n");
    return L;
}
//头插法插入单链表
/*LinkList Head_ListInsert(LinkList L){
    LNode *s;
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    L->next=NULL;
    printf("头插法插入数据:\n");
    scanf("%d",&x);
    while(x!=999){
        s=(LNode *)malloc(sizeof(LNode));
        s->data=x;
        s->next = L->next;
        L->next = s;
        printf("头插法插入数据:\n");
        scanf("%d",&x);
    }
    return L;
}*/

//尾插法插入单链表

LinkList Tail_ListInsert(LinkList L){
    
    int x;
    L=(LinkList)malloc(sizeof(LNode));
    LNode *s,*tail=L;
    printf("尾插法插入的数据:\n");
    scanf("%d",&x);
    while(x!=999){
    
        s=(LNode *)malloc(sizeof(LNode));
        s->data = x;
        tail->next = s;
        tail=s;
        printf("尾插法插入的数据:\n");
        scanf("%d",&x);
    }
    tail->next=NULL;
    return L;

}

//输出整个单链表
void Print(LinkList L){
    
    while(L->next!=NULL){
    
        L=L->next;
        printf("%d ",L->data);
    }
    printf("\n");
}
//按序号查找节点
LNode *GetElem(LinkList L,int i){
    
    if(i<1){
    
        printf("输入的位序不合法!\n");
        return NULL;
    }
    int j=1;
    LNode *p = L->next;
    while(p!=NULL&&j<i){
    
        p = p->next;
        j++;
    }
    return p;
}
//按值查找
LNode *GetElemByValue(LinkList L,int value){
    
    LNode *p = L->next;
    int i=1;
    while(p!=NULL&&p->data!=value){
    
        p=p->next;
        i++;
    }
    printf("该值所处的位序位%d\n",i);
    return p;
}
//按位序插入值
bool InsertByLocation(LinkList L,int i,int e){
    
    if(i<1){
    
        printf("待插入的位置不合法!\n");
        return false;
    }
    LNode * proNode = GetElem(L,i-1);
    LNode *s = (LNode *)malloc(sizeof(LNode));
    s->data = e;
    s->next = proNode->next;
    proNode->next = s;
    return true;
}
//在给定值进行前插操作
bool InsertProNode(LNode *p,int e){
    
    if(p==NULL){
    
        return false;
    }
    LNode *s = (LNode *)malloc(sizeof(LNode));
    if(s==NULL){
    
        return false;
    }
    s->next = p->next;
    p->next = s;
    s->data = p->data;
    p->data = e;
    return true;
}
//在给定节点执行后插操作
bool InsertNextNode(LNode *p,int e){
    
    if(p==NULL){
    
        return false;
    }
    LNode *s = (LNode *)malloc(sizeof(LNode));
    if(s==NULL){
    
        return false;
    }
    s->data = e;
    s->next = p->next;
    p->next = s;
    return true;
}
bool DeleteNode(LNode *p){
    
    if(p==NULL){
    
        return false;
    }
    LNode *q = p->next;
    p->data = p->next->data;
    p->next = q->next;
    free(q);
    return true;
}

int main(){
    
    LinkList L;
    InitList(L);
    //LinkList *p = Head_ListInsert(L);
    LinkList *l = Tail_ListInsert(L);
    //Print(p);
    //InsertByLocation(l,4,88);
    //printf("未插入前的链表数据为:\n");
    printf("未删除前的链表数据为:\n");
    Print(l);
    //LNode * pri = GetElem(l,4);
    //InsertProNode(pri,66);
    //InsertNextNode(pri,55);
    //printf("执行插入操作之后链表的数据为:\n");
    LNode *r = GetElemByValue(l,5);
    DeleteNode(r);
    printf("执行删除操作之后链表的数据为:\n");
    Print(l);
    //LNode *ele = GetElem(l,4);
    //printf("按位序查找的值位:%d\n",ele->data);
    //LNode *elem = GetElemByValue(l,7);
    //printf("按值查找的元素为:%d\n",elem->data);

    return 0;
}

运行结果:在这里插入图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_44697268/article/details/132513599

智能推荐

服务器发送信息给arduino,arduino通过esp8266模块发送数据到云服务器-程序员宅基地

文章浏览阅读1.4k次,点赞2次,收藏25次。arduino通过esp8266模块发送数据到云服务器我是代码小白,一个正在做毕设的秃头少年。鄙人拙作,有不当之处,还请指教。最近买了一套arduino设备,打算做一个物联网设备小玩意,可是怎么把数据上传到云服务器可愁坏我了。通过对比实验,我决定用esp8266wifi模块进行通信。云服务器的话,我现在还没写相应的代码,所以先用Onenet平台进行配置。Onenet平台进行配置1.进入Onenet..._esp8266 arduino wifi发送数据

latex h t b p是什么意思_latex htpb-程序员宅基地

文章浏览阅读1.4w次,点赞9次,收藏17次。常用选项[htbp]是浮动格式:『h』当前位置。将图形放置在正文文本中给出该图形环境的地方。如果本页所剩的页面不够,这一参数将不起作用。『t』顶部。将图形放置在页面的顶部。『b』底部。将图形放置在页面的底部。『p』浮动页。将图形放置在一只允许有浮动对象的页面上。在table或者figure 后加 [!htb] 是系统忽略“美学”标准,把表格和图片插入到你的代码中,是动的,但是不加感叹号,它就是按顺序选择h(此处),t(上方),b(下方),所以为了让图片随着你的代码移动,最好加一个[!htb]_latex htpb

【转载】linux下的usb抓包方法-程序员宅基地

文章浏览阅读67次。1 linux下的usb抓包方法1、配置内核使能usb monitor:make menuconfigDevice Drivers --> USB Support --> USB Monitor --> Sel..._linux安装tcpdump 查看usb

计算机组成pc em ir,计算机组成 课程设计报告.doc-程序员宅基地

文章浏览阅读164次。计算机组成 课程设计报告计算机组成原理课程设计报告姓 名:班 级:学 号:指导老师:2016年 6月31日目 录第一章 背景知识与课设任务概述11.1课设目的11.2课设任务11.2111.2211.2321.2421.252第二章 课设内容32.1指令的执行流程32.1.132.1.242.1.352.2存储器62.2.162.3运算器72.3.172.4硬件系统组成122.4..._计算机组成课程设计报告

python青果教务系统抢课_名额不够,技术来凑,利用Python实现教务系统强制性抢课...-程序员宅基地

文章浏览阅读1.3k次。最近一学期一次的抢课大戏又来了,几家欢乐几家愁。O(∩_∩)O哈哈~(l我每次一选就过了hah,我还是有欧的时候滴)。看着他们盯着教务系统就着急,何况我们那教务系统,不想说什么。emmm 想周围的朋友,正好下午利用扩容前一段时间写了个小脚本帮助朋友抢课。(当然抢到了啦,^_^)私信小编001即可获取大量Python学习资料,名额有限因为时间不够,来不及仔细琢磨,我第一想法就是直接提交选课的数据包(..._青果教务系统抢课

windows 加 switchyomega + burp 抓https包-程序员宅基地

文章浏览阅读4.6k次。很简单,下载证书后导入到受信任根目录证书下载,直接在代理状态浏览器访问burp点击CA就可以下载了 设置该证书全部信任,,switchyomega 设置如下即可 就可以抓https的包了 ...

随便推点

解决atom上gcc无法识别 <ros/ros.h>_ros类型无法识别-程序员宅基地

文章浏览阅读335次。找到插件 linter-gcc在Settings里找到GCC Inlude Path和GCC -isystemInclude Paths两栏填入ros的Include路径 /opt/ros/noetic/include注意ros版本不同路径可能有所不同,可以在先文件夹里找一找确定一下_ros类型无法识别

java 解析 modbus rtu_ModBus-RTU详解-程序员宅基地

文章浏览阅读5.7k次,点赞2次,收藏13次。Modbus 一个工业上常用的通讯协议、一种通讯约定。Modbus协议包括RTU、ASCII、TCP。其中MODBUS-RTU最常用,比较简单,在单片机上很容易实现。虽然RTU比较简单,但是看协议资料、手册说得太专业了,起初很多内容都很难理解。所谓的协议是什么?就是互相之间的约定嘛,如果不让别人知道那就是暗号。现在就来定义一个新的最简单协议。例如,协议: “A” --“LED灭”“B” --“报警..._java modbus4j-rtu 二进制数字意义

2021-07-18-程序员宅基地

文章浏览阅读43次。从零开始实现简易版本SpringIoC&DI&MVCSpring源码进修中,实现一个简易版本的Spring,包含以下主要内容:IoC,DI,MVC,已完成基本的功能。代码量还算一般,特此记录以共勉。首先是整个项目的基本思路。项目实现的功能就是从前端发一个请求,后端根据请求解析到后端的相应方法进行处理,完成后将结果进行返回。代码需要完成请求路径和类+方法的对应。配置阶段配置web.xml:DispatcherServlet设定init-param:contextConfigL

507页XX市应急管理局智慧矿山煤矿数字化矿山技术解决方案_18万字应急管理局智慧矿山煤矿数字化矿山技术解决方案word-程序员宅基地

文章浏览阅读542次。只有在单系统自动化的基础上,通过高速网络接入各单系统,充分数据融合,建立合理的联动机制才能完成从单系统自动化到综合自动化的转变,该部分的转变从投入的资金和实现的容易度相对来讲可实现性和可控性都比较容易,但是从综合自动化向数字化矿山发展,涉及的面比较广,必须由多方共同来推进,一般涉及到“综合自动化”、“空间数字化”及“管理信息化”三大方面,三者缺一不可,通过三者的有机融合,再通过合适的平台例如三维可视化平台进行展示,同时通过科学合理的管理制度和流程加以应用才是真正意义上有血有肉的数字化矿山。_18万字应急管理局智慧矿山煤矿数字化矿山技术解决方案word

Tomcat官网地址-程序员宅基地

文章浏览阅读1.4w次,点赞8次,收藏7次。Tomcat官网地址_tomcat官网

汇编指令长度计算_汇编指令占多少字节-程序员宅基地

文章浏览阅读5.1k次,点赞11次,收藏58次。指令长度与寻址方式有关系,规律或原则如下:一、没有操作数的指令,指令长度为1字节。如es:ds:cbwxlat等。二、操作数只涉及寄存器的指令,指令长度为2字节。如mov al,[si]mov ax,[bx+si]mov ds,ax等。三、操作数涉及内存地址的指令,指令长度为3字节。如mov al,[bx+1]mov ax,[bx+si+3]lea di,[1234]mov [2345],ax等。四、操作数涉及立即数的指令,指令长度为:寄存器类型+2。8位寄存器,寄存器_汇编指令占多少字节