ChinaUnix.net
相关文章推荐:

创建单项链表

一个单项链表,长度为百万量级,首指针为head 按a升序. 下面是别人写的一个. [code] # include typedef struct _node_t{ int a; struct _node_t* next; }node_t; node_t* Mergesort(node_t* L,int count) //链表头及要链表元数个数 { if(count==1) return L; int count1=count/2; int count2=count-count1; node_t* p=L; int i; for(i=0;i

by ufoace - C/C++ - 2006-05-21 12:08:28 阅读(1822) 回复(2)

相关讨论

[CODE] /* sqlink */ #include ; typedef struct list { char data; struct list *next; } SqlistNode; typedef SqlistNode *Sqlist; Sqlist creatlist(void) { char ch; Sqlist head,p; head=NULL; p=head; while((ch=getchar())!=' ') { p=p->;next; p->;data=ch; } printf("creat lintk ok.\n"); return head; //本以为返回的是创建成功后的头接点地址 } i...

by syshunter - C/C++ - 2003-09-29 09:39:26 阅读(1150) 回复(4)

typedef struct linknode { int data; struct linknode *next; }linknode,*linklist; void creatlist(linklist &L) { linklist head,p; int i; L=(linklist)malloc(sizeof(linknode)); if(!L) printf("malloc error;"); L->next=L; head=L; for(i=1;i<=10;i++) { p=(linklist)malloc(sizeof(linknode)); if(!p) printf("malloc error;"); p->data=i; L->next=p p->next=head; L=p; } } 创建时我传入的是一个 linklist指针,...

by jiean - C/C++ - 2009-02-03 10:48:23 阅读(6264) 回复(14)

Snort规则链表创建要经历两步, 首先是构建一个三维链表(规则动作作链表头) 然后是对这个链表进行二次分类,创建快速匹配链表(协议作链表头) 请问第一个步骤有什么作用,直接建立快速匹配的链表不就可以了? 难道是历史原因 请高手解答,谢谢

by monkeygreg - 行业应用和管理 - 2009-05-17 13:53:55 阅读(2905) 回复(1)

在 VC 6.0 下写的程序。 调试的时候发现creat_List()的返回值是对的。但是返回到main()以后,L的值就是无定义的了。然后就是show()的时候程序出错。 如果写成s how(creat_list(L, N)) 则可以正常输出。不明白为什么返回之后 L 的值会没定义呢。望指点。 #define N 3 typedef struct LNode { char data; struct LNode *next; }LNode; LNode* creat_list(LNode* L, int n){ LNode *p; L=(LNode *)malloc(si...

by modestyang - C/C++ - 2007-09-23 20:25:33 阅读(2454) 回复(10)

#include #include typedef struct LNode{ int data; struct LNode *next; }LNode,*LinkList; void initlist(LinkList L); int Inselem(LinkList L,int i,int x); void displist(LinkList L); int Getlen(LinkList L); main() { LinkList List=NULL; int ii,xx,error,counter; initlist(List); printf("Please enter the linklist size:"); scanf("%d",&List->data); printf("\...

by ktzlj - C/C++ - 2006-11-30 17:07:16 阅读(907) 回复(0)

Creat_L(Linklist *L,int n) { Linklist *p;int i; Initlist(L); //建立一个带头结点的单链表 for(i=0;idata); p->next=L->next; L->next=NULL; } } 这是一个从表尾到表头输入N个元素的值,建立单链表的算法,请高手写一个从表位插入新结点建表的方法。 [ 本帖最后由 誓不_低...

by 誓不_低头 - C/C++ - 2005-12-11 22:21:51 阅读(666) 回复(1)

:oops: :oops: [code] # include "stdio.h" # include "stdlib.h" struct st{ int a; struct st *next; } main () { int n; struct st *p,*q,*head; head=p=q=NULL; scanf ("%d",&n); clrscr(); while (n!=0) { p=(struct st*)malloc(sizeof(struct st)); p->;a=n; if (head==NULL) p=head; else { q=p; p=q->;next; } p->;next=NULL; scanf ("%d",&n); } p=head; while (p!=NULL) { printf ("...

by wujiajia - C/C++ - 2004-05-28 19:19:20 阅读(489) 回复(5)

请看一下是哪的问题 struct time_save { char str_time[20]; int str_fresh; struct time_save *next; }; 我想定写一个函数 struct time_save addstu(struct time_save *thread,char *time,int fresh_site) 其中thread为给定一个结构体,char *time,int fresh_site,为一个结构的两项要插入到thread,并返回thread结构体 请各位帮一下

by stiandao - C/C++ - 2005-12-03 14:50:51 阅读(867) 回复(5)

:( 程序如下: dlinklist *CREATLIST() { char ch; head=NULL; p=head; printf("\nPLEASE ENTER CHAIN BELT:(PRESS '*' TO EXIT)\n"); ch=getchar(); while(ch!='*') { s=(dlinklist *)malloc(LEN); s->;data=ch; p->;next=s; s->;prior=p; p=s; ch=getchar(); } head->;prior=p; p->;next=head;/*-------------------将尾接点连到头接点-----------...

by senfar - C/C++ - 2004-03-18 12:56:50 阅读(1342) 回复(8)