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

上传人:无*** 文档编号:171172355 上传时间:2022-11-24 格式:DOC 页数:8 大小:114.50KB
收藏 版权申诉 举报 下载
单词本考试系统(c语言版)_第1页
第1页 / 共8页
单词本考试系统(c语言版)_第2页
第2页 / 共8页
单词本考试系统(c语言版)_第3页
第3页 / 共8页
资源描述:

《单词本考试系统(c语言版)》由会员分享,可在线阅读,更多相关《单词本考试系统(c语言版)(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);截图

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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