当前位置: 首页> 游戏> 网游 > 免费接单平台_进入公众号怎么找出二维码_网站优化员seo招聘_google网站增加关键词

免费接单平台_进入公众号怎么找出二维码_网站优化员seo招聘_google网站增加关键词

时间:2025/7/11 2:44:19来源:https://blog.csdn.net/longspython/article/details/144543567 浏览次数:1次
免费接单平台_进入公众号怎么找出二维码_网站优化员seo招聘_google网站增加关键词

一、loopLink.h

#ifndef __LOOPLINK_H__
#define __LOOPLINK_H__#include <stdio.h>
#include <stdlib.h>typedef int DataType;typedef struct node
{union{int len;DataType data;};struct node* next;
}loopLink, *loopLinkPtr;//创建
loopLinkPtr create();//判空
int empty(loopLinkPtr H);//尾插
int tail_add(loopLinkPtr H, DataType e);//遍历
void show(loopLinkPtr H);//尾删
int tail_del(loopLinkPtr H);//销毁
void my_free(loopLinkPtr H);#endif

二、loopLink.c

#include "loopLink.h"//创建
loopLinkPtr create()
{loopLinkPtr H = (loopLinkPtr)malloc(sizeof(loopLink));if(NULL == H){printf("创建失败!\n");return NULL;}H->len = 0;H->next = H;printf("创建成功!\n");return H;
}//判空
int empty(loopLinkPtr H)
{if(NULL == H){printf("判空失败!\n");return -1;}return H->len==0;
}//尾插
int tail_add(loopLinkPtr H, DataType e)
{if(NULL == H){printf("尾插失败!\n");return 0;}loopLinkPtr p = (loopLinkPtr)malloc(sizeof(loopLink));if(NULL == p){printf("申请节点失败!\n");return 0;}p->data = e;p->next = NULL;loopLinkPtr q = H;while(q->next != H){q = q->next;}q->next = p;p->next = H;H->len++;return 1;
}//遍历
void show(loopLinkPtr H)
{if(NULL == H || empty(H)){printf("遍历失败!\n");return ;}loopLinkPtr p = H;for(int i=0; i<H->len; i++){p = p->next;printf("%d ", p->data);}printf("\n");
}//尾删
int tail_del(loopLinkPtr H)
{if(NULL == H || empty(H)){printf("删除失败!\n");return 0;}loopLinkPtr q = H;for(int i=0; i<H->len-1; i++){q = q->next;}free(q->next);q->next = H;H->len--;return 1;
}//销毁
void my_free(loopLinkPtr H)
{if(NULL == H){printf("销毁失败!\n");return ;}while(H->next != H){tail_del(H);}free(H);H=NULL;printf("销毁成功!\n");
}

三、main.c

#include "loopLink.h"int main()
{loopLinkPtr H = create();tail_add(H, 10);tail_add(H, 20);tail_add(H, 30);tail_add(H, 40);tail_add(H, 50);show(H);//尾删tail_del(H);show(H);//销毁my_free(H);H=NULL;return 0;
}

四、执行结果

五、知识点思维导图

关键字:免费接单平台_进入公众号怎么找出二维码_网站优化员seo招聘_google网站增加关键词

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: