英汉字典

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include

#include

#include

#include

struct node{

char word[30];

char ch[40];

struct node *next;

};

struct node *head;

struct node *q;

void gongneng();

void write();

//查询单词

void chaxun(){

system("cls");

struct node *p,*t;

int flag=0;

int n;

p=(struct node *)malloc(sizeof(struct node));

t=(struct node *)malloc(sizeof(struct node));

t=head;

printf("\n请输入要查询的单词:");scanf("%s",&p->word);

do{

if(strcmp(t->word,p->word)==0) {flag=1;break;}

else t=t->next;

}while(t);

if(flag==1) {printf("%s %s\n",t->word,t->ch);}

else {printf("\n该单词不存在!!!\n");}

printf("\n\n1 继续查询!\n2 返回!\n其他任意键退出!\n\n\n请选择:");

scanf("%d",&n);

if(n==1) chaxun();

else if(n==2) {system("CLS");gongneng();}

else {printf("\n是否保存到文件\n\n\n1 是!\n0 否!\n请选择:");

int m;

scanf("%d",&m);

if(m==1) write();

exit(-1);}

}

//修改单词

void change(){

system("cls");

struct node *p,*t;

int flag=0,n,len;

p=(struct node *)malloc(sizeof(struct node));

t=(struct node *)malloc(sizeof(struct node));

t=head;

printf("\n请输入要修改的单词:");scanf("%s",&p->word);

do{

if(strcmp(t->word,p->word)==0) {flag=1;break;}

else t=t->next;

}while(t);

if(flag==1) {

printf("\n请输入该单词的信息:");scanf("%s",&t->ch);len=strlen(t->ch);t->ch[len]='\n';

}

else {printf("\n该单词不存在!!!!\n");}

printf("\n\n\n1 继续修改!\n2 返回!\n其他任意键退出!\n\n请选择:");

scanf("%d",&n);

if(n==1) change();

else if(n==2) {system("CLS");gongneng();}

else {printf("\n是否保存到文件\n\n\n1 是!\n0 否!\n请选择:");

int m;

scanf("%d",&m);

if(m==1) write();

exit(-1);}

}

//添加单词

void add(){

system("cls");

struct node *p,*t,*s;

int n,flag=0,len;

p=(struct node *)malloc( sizeof(struct node));

t=(struct node *)malloc(sizeof(struct node));

s=(struct node *)malloc(sizeof(struct node));

s=head,t=head->next;

printf("\n请输入添加的单词:");scanf("%s",&p->word);len=strlen(p->word);p->word[len]=' ';

printf("\n请输入该单词的信息:");scanf("%s",&p->ch);len=strlen(p->ch);p->ch[len]='\n';

while(s){

if((strcmp(p->word,s->word)>0)&&(strcmp(p->word,t->word)<0)){

p->next=s->next;s->next=p;flag=1;break;}

else if(strcmp(p->word,s->word)==0) {printf("\n该单词已存在!!!\n");break;}

else {s=s->next,t=t->next;}}

if(flag==1) printf("\n\n添加成功!\n");

printf("\n1 继续添加!\n2 返回!\n其他键退出!\n\n\n请选择:");

scanf("%d",&n);

if(n==1) add();

相关文档
最新文档