一个单项链表,长度为百万量级,首指针为head
按a升序.
下面是别人写的一个.
[code]
# include
by
ufoace
-
C/C++
-
2006-05-21 12:08:28 阅读(1822) 回复(2)
[CODE]
/* sqlink */
#include
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指针,...
Snort规则链表的创建要经历两步, 首先是构建一个三维链表(规则动作作链表头) 然后是对这个链表进行二次分类,创建快速匹配链表(协议作链表头) 请问第一个步骤有什么作用,直接建立快速匹配的链表不就可以了? 难道是历史原因 请高手解答,谢谢
在 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...
#include
Creat_L(Linklist *L,int n)
{
Linklist *p;int i;
Initlist(L); //建立一个带头结点的单链表
for(i=0;i
: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 ("...
请看一下是哪的问题 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结构体 请各位帮一下
:( 程序如下: 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;/*-------------------将尾接点连到头接点-----------...