C语言版本:循环单链表的实现】的更多相关文章

未优化版本:http://www.cnblogs.com/duwenxing/p/7569376.html slist.h #ifndef __SLIST_H__ #define __SLIST_H__ #include<cstdio> #include<malloc.h> #include<assert.h> typedef int ElemType; typedef struct Node { //定义单链表中的结点信息 ElemType data; //结点的数据…
slist.h #ifndef __SLIST_H__ #define __SLIST_H__ #include<cstdio> #include<malloc.h> #include<assert.h> typedef int ElemType; typedef struct Node { //定义单链表中的结点信息 ElemType data; //结点的数据域 struct Node *next; //结点的指针域 }Node,*PNode; typedef st…
//初始化 Node*InitList() { Node*head=(Node*)malloc(sizeof(Node)); head->next=NULL; head->data=-1; return head; } 增加数据 void Add(Node*s) { Node*p=s; int n; printf("你要输入多少数据:"); scanf("%d",&n); printf("请输入%d个数据:",n); for(…
SClist.h #ifndef __SCLIST_H__ #define __SCLIST_H__ #include<cstdio> #include<malloc.h> #include<assert.h> typedef int ElemType; typedef struct Node { ElemType data; struct Node *next; }Node,*PNode; typedef struct List { PNode first; PNod…
/************************************************************************* > File Name: singleLineTable.c > Author: zshh0604 > Mail: zshh0604@.com > Created Time: 2014年10月15日 星期三 11时34分08秒 ******************************************************…
/************************************************************************* > File Name: singleLineTable.c > Author: zshh0604 > Mail: zshh0604@.com > Created Time: 2014年10月15日 星期三 11时34分08秒 ******************************************************…
/***************************************************** Author:Simon_Kly Version:0.1 Date: 20170520 Description:循环单链表 Mail:degaullekong@gmail.com Funcion List: *****************************************************/ #include <stdio.h> #include <std…
#include <stdio.h> #include <stdlib.h> /** * 含头节点循环单链表定义,初始化 及创建 */ #define OK 1; #define ERROR 0; //函数返回类型,表示函数运行结果的状态 typedef int Status; //定义数据元素类型 typedef char ElemType; //循环单链表定义 typedef struct LoopLnode { ElemType data; //数据域,这里是char类型变量…
C代码实现非循环单链表, 直接上代码. # include <stdio.h> # include <stdlib.h> # include <malloc.h> //C代码实现非循环单链表 //定义链表结点 typedef struct Node{ int data;//数据域 struct Node* pNext;//指针域 }* PNODE,NODE; //函数声明 PNODE initHead(void); void init(PNODE pHead) ; bo…
刚刚接触C++以及数据结构,今天做了第一次尝试用C++和数据结构解决问题,问题是基于约瑟夫环问题的简单版. 先来看看约瑟夫环问题的介绍: 约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围.从编号为k的人开始报数,数到m的那个人出列:他的下一个人又从1开始 报数,数到m的那个人又出列:依此规律重复下去,直到圆桌周围的人全部出列.(摘自百度百科) 程序的输入应该由三个值组成(n, k, m),接下来程序将会自动运行,本文假设每次都从第一个人开始报数,所以…