链表加法
/************************************************************************* > File Name: list.h > Author: zhoulin > Mail: 715169549@qq.com > Created Time: Sat 16 Apr 2016 10:58:58 AM CST ************************************************************************/ #ifndef _LIST_H //define a node of list typedef struct _baseNode { int v; struct _baseNode *next; }baseNode; baseNode *listAdd(baseNode *p1,baseNode *p2); baseNode *listInsert(baseNode *b,int v); void listFree(baseNode *p); #define _LIST_H #endif
listc:
/************************************************************************* > File Name: list.c > Author: zhoulin > Mail: 715169549@qq.com > Created Time: Sat 16 Apr 2016 11:04:56 AM CST ************************************************************************/ #include "list.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define size 64 void listPrt(baseNode *p) { while(p != NULL) { if(p->next == NULL) { fprintf(stdout," %d ",p->v); break; } fprintf(stdout,"%d ->",p->v); p = p->next; } } baseNode *listInsert(baseNode *b,int v) { char pbuf[size] = {'