单词本考试系统(c语言版).doc

上传人:飞****2 文档编号:63856552 上传时间:2022-11-27 格式:DOC 页数:8 大小:114.50KB
返回 下载 相关 举报
单词本考试系统(c语言版).doc_第1页
第1页 / 共8页
单词本考试系统(c语言版).doc_第2页
第2页 / 共8页
点击查看更多>>
资源描述

《单词本考试系统(c语言版).doc》由会员分享,可在线阅读,更多相关《单词本考试系统(c语言版).doc(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、 单词管理考试系统(链表、结构体、文本读取与保存)注意:请使用的同学替换程序中本人的姓名! 本程序仅供大家参考,亦可应付大学作业检查,谢谢 -陆鑫使用到的函数及其功能说明:(1)void initial(SLNode * head);初始化链表,从文本读取数据并且添加到链表。(2)void printallwords(SLNode * head);遍历链表并且打印。(3)void addnewwords(SLNode * head);添加新单词到链表并且写入到文本。(4)void deleteoldwords(SLNode * head)从链表中删除指定元素,并从文本中删除。(5)void e

2、nglishtest(SLNode * head)根据中文翻译英文测试,最后能计算出结果及正确率。(6)void chinesetest(SLNode * head)根据英文翻译中文测试,最后能计算出结果及正确率。(7)void rewrite(SLNode * head)在对文本进行修改时,通过调用此函数实现对文本的修改。2、源代码recite.c#include#include#include#includerecite.hvoid main()SLNode * head=NULL;int choice;init(&head);printf(+-欢迎使用-+n|n|n);printf(|t

3、 1.浏览全部单词 2.添加新单词3.删除已存在单词n);printf(|t 4.英文测试 5.中文测试6.退出程序n);printf(|ttttttt 制作者:陆鑫n);printf(|n+-欢迎使用-+nnn);while(1)scanf(%d,&choice);switch (choice)case 1:printallwords(head);break;case 2:addnewwords(head);break;case 3:deleteoldwords(head);break;case 4:englishtest(head);break;case 5:chinesetest(hea

4、d);break;case 6:exit6();return; break;default:printf(输入错误!n);break;printf(nt |n);printf(t | 1.浏览全部单词 2.添加新单词 3.删除已存在单词 |n);printf(t | 4.英文测试 5.中文测试 6.退出程序 |n);printf(t n);recite.htypedef struct nodechar english20;char chinese20;struct node * next;SLNode;int count=0;int flag=0;void rewrite(SLNode * h

5、ead)FILE * fp;SLNode * L=head;if (fp=fopen(English_vocabulary.txt,w)=NULL)putchar(7);printf(文件打开失败!n);exit(0);L=L-next-next;while(L!=NULL)fputs(L-english,fp);fputc(n,fp);fputs(L-chinese,fp);fputc(n,fp);L=L-next;void init (SLNode * head)FILE * fp;double nr_word=1,nr_explain=1;SLNode * L;(*head)=(SLNo

6、de*)malloc(sizeof(SLNode);(*head)-next=NULL;if (fp=fopen(English_vocabulary.txt,a+)=NULL)putchar(7);printf(文件打开失败!n);exit(0);while (nr_word0&nr_explain0)L=(SLNode*)malloc(sizeof(SLNode);nr_word=fscanf(fp,%s,&(L-english);nr_explain=fscanf(fp,%s,&(L-chinese);L-next=(*head)-next;(*head)-next=L;count+;i

7、f (count=1)flag=-1;fclose(fp);void printallwords(SLNode * head)SLNode * L=head;L=L-next-next;if (flag=-1)putchar(7);printf(tttt当前单词本为空!nn);return;while(L!=NULL)printf(tt%-10s:tt,L-english);printf(t%-10sn,L-chinese);L=L-next;printf(nn);void addnewwords(SLNode * head)FILE * fp;char eng20,chi20;SLNode

8、* L;flag=0;L=(SLNode*)malloc(sizeof(SLNode);if (fp=fopen(English_vocabulary.txt,a+)=NULL)putchar(7);printf(文件打开失败!n);return;printf(请输入需要添加的单词:);scanf(%s,eng);printf(请输入需要添加单词的中文:);scanf(%s,chi);strcpy(L-english,eng);strcpy(L-chinese,chi);fputs(eng,fp);fputc(n,fp);fputs(chi,fp);fputc(n,fp);L-next=hea

9、d-next-next;head-next-next=L;fclose(fp);void deleteoldwords(SLNode *head)SLNode * L=head;SLNode * P;char del_wor20;if (flag=-1)putchar(7);printf(ttt单词本为空!nn);return;L=L-next;printf(请输入您想要删除的单词:tt);scanf(%s,del_wor);while(L-next!=NULL)if (strncmp(del_wor,L-next-english,15)=0)P=L-next;L-next=L-next-ne

10、xt;free(P);printf(ttt删除成功!nn);rewrite(head);return;L=L-next;putchar(7);printf(nnttt无此单词!nnn);void englishtest( SLNode*head )SLNode * L=head;int error=0,total=0;char rule20,input20;L=L-next-next;if (flag=-1)putchar(7);printf(tttt当前单词本为空!nn);return;while(L!=NULL)total+;printf(t%10s:tt,L-chinese);strcp

11、y(rule,L-english);scanf(%s,input);if (strncmp(input,rule,15)!=0)putchar(7);error+;printf(ttttttt错误.n);L=L-next;printf(本次共测%d个单词,您错误%d个,准确率%.2f%nn,total,error,(float)(total-error)/total)*100);void chinesetest(SLNode * head)SLNode * L=head;int error=0,total=0;char rule20,input20;L=L-next-next;if (flag

12、=-1)putchar(7);printf(tttt当前单词本为空!nn);return;while(L!=NULL)total+;printf(t%10s:tt,L-english);strcpy(rule,L-chinese);scanf(%s,input);if (strncmp(input,rule,15)!=0)putchar(7);error+;printf(ttttttt错误.n);L=L-next;printf(本次共测%d个单词,您错误%d个,准确率%.2f%nn,total,error,(float)(total-error)/total)*100);void exit6()printf(tttt感谢您的使用!ttttn);截图

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com