日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

关键字搜索 c语言,c语言-以关键字搜索程序

發布時間:2024/10/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关键字搜索 c语言,c语言-以关键字搜索程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該樓層疑似違規已被系統折疊?隱藏此樓查看此樓

#include

#include

#include

typedef?struct?CharList_Node{

char?*data;

int?vaul;

struct?CharList_Node?*next;

}cnode;

typedef?struct?Int_Node{

cnode?*bat;

struct?Int_Node?*next;

}intnode;

typedef?struct?IndexList_Node{

char?*info;

intnode?*code;

struct?IndexList_Node?*next;

}inode;

cnode?*CreatCharList()

{

cnode?*head,*hp,*tp;

char?*a;

char?*b="n";

int?x;

a=(char*)malloc(sizeof(char));

head=(cnode*)malloc(sizeof(cnode));

head->next=NULL;

hp=head;

printf("Input?the?CharList,compelete?by?enter?'n'?and?number?'0'.:\n");/*建立詞表,輸入字符串,以輸入“n”+”回車”以及“0”+"回車”?結束*/

while(EOF!=(scanf("%s""%d",a,&x))&&(*a!=*b))

{

tp=(cnode*)malloc(sizeof(cnode));

strcpy(tp->data,a);

tp->vaul=x;

tp->next=hp->next;

hp->next=tp;

hp=tp;

}

return?head;

}

void?PrintCharList(cnode?*phead)

{

cnode?*p;

p=phead->next;

printf("Output?the?CharList?Vaul:\n");

while(p)

{

printf("%s??""%d\n",p->data,p->vaul);

p=p->next;

}

}

intnode?*Compare(char?*x,cnode?*chead)

{

int?i;

int?j;

int?k;

char?*a;

intnode?*ptr,*hp,*tp;

cnode?*p;

ptr=NULL;

p=chead->next;

ptr=(intnode*)malloc(sizeof(intnode));

ptr->next=NULL;

hp=ptr;

while(p)

{?a=p->data;

i=0;

j=0;

k=0;

while((k

{

if(*(x+i)==*(a+j))

{

i++;

j++;

}

else

{

j=++k;

i=0;

}

if(i==(strlen(x)))

{

tp=(intnode*)malloc(sizeof(intnode));

tp->next=hp->next;

tp->bat=p;

hp->next=tp;

hp=tp;

}

}

p=p->next;

}

return?ptr;

}

void?PrintCode(intnode?*inthead)

{

intnode?*p;

p=inthead->next;

while(p)

{

printf("%d?""%s\n",p->bat->vaul,p->bat->data);

p=p->next;

}

}

void?PrintIndexList(inode?*ihead)

{

inode?*ip;

intnode?*intp;

ip=ihead->next;

while(ip)

{

printf("%s:?",ip->info);

intp=ip->code;

PrintCode(intp);

ip=ip->next;

printf("\n");

}

}

main()

{

cnode?*pp;

intnode?*pr;

inode?*ihead,*hp,*tp;

char?*a;

char?*b="n";

ihead=(inode*)malloc(sizeof(inode));

ihead->next=NULL;

hp=ihead;

a=(char*)malloc(sizeof(char));

pp=CreatCharList();

PrintCharList(pp);

printf("Please?intput?index?information?,complete?by?'n':\n");/*輸入索引關鍵字,以輸入"n"+”回車”結束*/

while(EOF!=scanf("%s",a)&&(*a!=*b))

{

pr=Compare(a,pp);

tp=(inode*)malloc(sizeof(inode));

tp->next=hp->next;

strcpy(tp->info,a);

tp->code=pr;

hp->next=tp;

hp=tp;

printf("%s:?",tp->info);

PrintCode(pr);

printf("\n");

}

printf("Press?key?of?'y'?output?the?IndexList?information,overview?by?'n':\n");/*輸入”y”+”回車”打印索引表,輸入"n"+”回車”?退出程序。*/

while(EOF!=scanf("%s",a)&&(*a!=*b))

{

PrintIndexList(ihead);

}

return?0;

}

總結

以上是生活随笔為你收集整理的关键字搜索 c语言,c语言-以关键字搜索程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。