双向循环链表Word格式.docx

上传人:b****5 文档编号:19679776 上传时间:2023-01-08 格式:DOCX 页数:19 大小:17.89KB
下载 相关 举报
双向循环链表Word格式.docx_第1页
第1页 / 共19页
双向循环链表Word格式.docx_第2页
第2页 / 共19页
双向循环链表Word格式.docx_第3页
第3页 / 共19页
双向循环链表Word格式.docx_第4页
第4页 / 共19页
双向循环链表Word格式.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

双向循环链表Word格式.docx

《双向循环链表Word格式.docx》由会员分享,可在线阅读,更多相关《双向循环链表Word格式.docx(19页珍藏版)》请在冰豆网上搜索。

双向循环链表Word格式.docx

ö

intinsert(LINKp2);

å

intdel(LINKp2,intm);

/*É

¾

voidcreat();

²

¢

½

Á

voidread();

/*¶

¡

Ä

¼

þ

Ú

Ý

voidwrite_fp();

/*Ð

/**********************************************************************/

voidexchange(LINKp1,LINKp2);

LINKcompare(LINKsp,chardn,chardm);

/*±

Ï

LINKbts(LINKsp,LINKp1,LINKp2,chardm);

/*´

Ó

ó

µ

Ð

Å

LINKstb(LINKsp,LINKp1,LINKp2,chardm);

chara;

FILE*fp;

LINKout_fp;

intd,num,menu;

/*menu²

Ë

¥

¿

Ø

Æ

if((fp=fopen("

C:

\\table.txt"

"

r"

))==NULL)/*´

ò

ª

{

printf("

Cannotopenthefile!

\nNowtheprogramwillbuildanewfile!

\n"

);

fp=fopen("

wt+"

creat();

out_fp=head;

do

{

fprintf(fp,"

%d%s%s%d%d\n"

out_fp->

data,out_fp->

name,\

out_fp->

tel,out_fp->

age,out_fp->

scoure);

out_fp=out_fp->

next;

}while(out_fp!

=head);

fclose(fp);

/*¹

}

else

read();

output(head);

/*************************************************************************************/

do

{

/*****Commandmenulist*****/\n1.Search\n2.Insert\n3.Delete\n4.Arrangement\n\

0.Exit\n"

/*Ö

÷

î

£

¬

Ò

É

Í

{

printf("

Pleaseselectanoption:

"

a=getch();

%c\n"

a);

if(a=='

1'

break;

elseif(a=='

2'

3'

4'

0'

exit

(1);

else

menu=1;

}while(menu);

/*********************************************/

if(a=='

chardm,dn;

Orderof(1.name2.scoure)?

:

dm=getch();

dm);

if((dm=='

)||(dm=='

))

Orderfrom(1.bigtosmall2.smalltobig)?

dn=getch();

dn);

if((dn=='

)||(dn=='

head=compare(head,dn,dm);

else

InvalidOptions!

}

else

output(head);

/************************************************/

Savetothefile?

(y/n):

y'

{

write_fp();

printf("

Savecomplete!

}

n'

read();

}while((a!

='

)&

&

(a!

));

Orderagain?

num=1;

{num=0;

menu=1;

}

 

}while(num);

read();

/************************************************************************************/

elseif(a=='

printf("

Pleaseentertheitemsyouwanttosearch:

\n\

(1.name2.tel3.age4.scoure):

Options:

/*fflush(stdin);

/*Ç

IO»

Ç

ø

d=getch();

d);

search(head,(char)d);

do

Searchagain?

a=getch();

if(a=='

num=1;

{num=0;

}while((a!

}while(num);

/****************************search********************************/

/**********************************************************************************/

Insertdata?

num=insert(head);

{num=0;

/***********************************************************************************/

{

whichnumberdoyouwanttodelete:

NO."

d=getch();

num=del(head,d);

output(head);

Deleteagain?

{

printf("

scanf("

%d"

&

d);

while((a=getchar())!

\n'

a!

=EOF);

/*Ë

Â

num=del(head,d);

output(head);

}

/****************************************************************************/

write_fp();

menu=0;

menu=1;

}while(menu);

exit

(1);

charsearch(LINKp,charn)/****************************²

********************************/

LINKa=p;

charb[9];

intc;

if((n=='

)||(n=='

Enterthecontent:

scanf("

%s"

b);

if((strcmp(a->

name,b)==0)||(strcmp(a->

tel,b)==0))

%3d.|%8s|%15s|%8d|%8d|\n"

a->

data,\

a->

name,a->

tel,a->

age,a->

return(0);

a=a->

}while(a!

=p);

NoData\n"

return(0);

elseif((n=='

c);

if((a->

age==c)||(a->

scoure==c))

return(0);

voidoutput(LINKsp)/********************************Ê

***********************************/

inti;

sp=head;

\nnum|name|tel|age|scoure|\n"

for(i=1;

;

i++)

sp->

data=i;

/****×

Ô

à

****/

sp->

sp->

name,sp->

tel,sp->

age,sp->

sp=sp->

if(sp==head)

break;

intinsert(LINKp2)/***************************²

****************************************/

LINKsp,newnode;

inti=0;

sp=p2->

front;

newnode=(LINK)malloc(sizeof(structlist));

if(newnode==NULL)

ERROR\n"

return

(1);

in_put(newnode);

newnode->

next=sp->

sp->

next->

front=newnode;

front=sp;

next=newnode;

insertcomplete!

return

(1);

intdel(LINKp2,intm)/*É

ã

LINKsp;

inta,i=0;

sp=p2;

i++;

while(sp!

if(m==1)

head=head->

if((1<

m)&

(m<

=i))

for(a=1;

a<

m;

a++)

sp=sp->

if((m>

i)||(m<

1))

outoforder\n"

front->

front=sp->

free(sp);

deletecomplete!

voidcreat()/*´

LINKpb,newnode;

for(i=0;

newnode=(LINK)malloc(sizeof(structlist));

{

newnode->

data=i+1;

in_put(newnode);

num|name|tel|age|scoure|\n"

newnode->

name,newnode->

tel,newnode->

age,newnode->

sure?

(press'

tocontinue):

/*·

À

¹

}while((a=getch())!

if(i==0)

{pb=head=newnode;

head->

front=NULL;

next=NULL;

}/*Ë

«

õ

{pb->

/*½

front=pb;

pb=newnode;

\nInsertagain?

if((a=getch())=='

continue;

break;

head->

pb->

next=head;

ê

voidread()/*¶

/*numÁ

fp=fopen("

fscanf(fp,"

newnode->

data,&

&

tel,&

age,&

pb=head=newnode;

}/*Ë

pb->

if(feof(fp))break;

head->

pb->

}

voidwrite_fp()/*Ð

if((fp=fopen("

))==NULL)/*Ð

LINKin_put(LINKp)/*Ê

pleaseinputthename:

scanf("

p->

name);

pleaseinputthetel:

tel);

pleaseinputtheage:

scanf("

age);

pleaseinputthescoure:

scanf("

return(p);

/****************************************************************************************/

LINKcompare(LINKsp,chardn,chardm)

LINKp1,p2,p0;

p1=p0=sp;

p2=p1->

if(dn=='

if(dm=='

for(;

p2!

=sp;

p2=p2->

next)

{

if(strcmp(p2->

name,p1->

name)>

0)

p1=p2;

}

sp=p1;

p0=sp;

(p0->

next)!

p0=p0->

p1=p0->

p2=p1->

for(;

if(p0->

next!

=p1)

exchange(p0,p1);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1