完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
#include
#include #include struct word { char chinese[30]; char english[30]; }; int main() { int point=0,count1=0,count=0,n; int *p,*c1,*c; p=&point; c1=&count1; c=&count; struct word str[100]; char ch; void tianjia(struct word str[100],int *c); void shuchu(struct word str[100],int *c); void fanyi1(struct word str[100],int *c,int *c1,int *p); void fanyi2(struct word str[100],int *c,int *c1,int *p); void chaxun(struct word str[100],int *c,int *c1,int *p); void change(); while(1) { change(); printf("请输入您要的操作选择:n"); scanf("%d",&n); switch(n) { case 1:tianjia(str,c);break; case 2:fanyi1(str,c,c1,p);break; case 3:fanyi2(str,c,c1,p);break; case 4:shuchu(str,c);break; case 5:chaxun(str,c,c1,p);break; case 0: { printf("您确定要退出此操作吗?yes/no?n"); scanf("%c",&ch); if(ch=='y'||ch=='Y') exit(0); } default:printf("您输入了错误的操作,无法执行!!"); exit(0); } } while(1); return 0; } void change() { printf("*************单词系统****************n"); printf("************1.单词输入***************n"); printf("************2.英译汉训练*************n"); printf("************3.汉译英训练*************n"); printf("************4.输出所有单词及对应中文*n"); printf("************5.训练成绩查询***********n"); printf("************0.退出*************n"); } void tianjia(struct word str[100],int *c) { char a; int count=0; c=&count; do { printf("单词输入!n请输入要录入词库的英文单词:n"); scanf("%s",str[count].english); printf("n请输入相应的中文意思:n"); scanf("%s",str[count].chinese); count++; printf("是否继续添加单词?y/n?n"); scanf("%s",&a); }while(a=='y'); printf("输入单词个数为:%dn",count); } void shuchu(struct word str[100],int *c) { int i,count; struct word *a; a=str; count=*c; printf("输出词库中所有的单词!n"); if(count<=0) printf("词库中没有单词,无法输出!n"); else { for(i=0;i printf("n"); } printf("词库中所有单词已输出!!n"); } void fanyi1(struct word str[100],int *c,int *c1,int *p) { int i,point,count1; c1=&count1; p=&point; char ch[30]; printf("现在进行英译汉训练!n"); for (i=0;i<(*c);i++) { printf("英文单词:%sn",str[i].english); printf("请输入中文翻译:"); scanf("%s",ch); if(strcmp(ch,str[i].chinese)==0) { point++; count1++; printf("恭喜你,答对了!n"); } else { count1++; printf("很遗憾,你答错了,再接再厉!n正确的翻译是:%sn",str[i].chinese); } } } void fanyi2(struct word str[100],int *c,int *c1,int *p) { int i,point,count1; c1=&count1; p=&point; char en[30]; printf("现在进行汉译英训练!n"); for (i=0;i<*c;i++) { printf("中文意思:%sn",str[i].chinese); printf("请输入英文单词:"); scanf("%s",en); if(strcmp(en,str[i].english)==0) { point++; count1++; printf("恭喜你,答对了!n"); } else { count1++; printf("很遗憾,你答错了,再接再厉!n正确的翻译是:%sn",str[i].english); } } } void chaxun(struct word str[100],int *c,int *c1,int *p) { printf("本次测试成绩是:n"); printf("测试次数为:%dn",*c1); printf("正确次数为:%dn",*p); printf("本次测试的正确率为:%d%n",*p *100/ *c1); if((*p *100/ *c1)<60) printf("有待提高,继续努力!"); else if(60<=(*p *100/ *c1)&&(*p *100/ *c1)<80) printf("成绩良好,再接再厉"); else if((*p *100 / *c1)>=80) printf("成绩优秀,继续保持"); } |
|
相关推荐
11 个讨论
|
|
|
|
|
|
|
|
|
|
|
|
#include #include #include typedef struct strWord { char strChinese[30]; char strEnglish[30]; }STRWORD,*PSTRWORD; STRWORD strBuf[100]; void TianJia(PSTRWORD pStrBuf,int *pCnt) { char a; do { printf("单词输入!n请输入要录入词库的英文单词:n"); scanf("%s",pStrBuf[*pCnt].strEnglish); printf("n请输入相应的中文意思:n"); scanf("%s",pStrBuf[*pCnt].strChinese); (*pCnt)++; printf("是否继续添加单词?y/n?n"); scanf("%s",&a); }while(a=='y'); printf("输入单词个数为:%dn",*pCnt); } int main() { int iCount=0; TianJia(strBuf,&iCount); } 大致是如此了,剩下的自己改吧。 |
|
|
|
|
|
|
|
|
1)函数声明要放到主函数外,或者.h文件中,函数体如果在 main()函数前面就不用声明了。
2)fun(struct word str[100]) 形参应该是 fun(word str[]),或使用指针代替 3)int Count ; fun(int *c) 可以直接 fun(&Count) 4) scanf("%s",&a); 有内存访问越界的嫌疑。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
你正在撰写讨论
如果你是对讨论或其他讨论精选点评或询问,请使用“评论”功能。
384 浏览 0 评论
398 浏览 0 评论
405 浏览 0 评论
780 浏览 0 评论
RT-Thread与英飞凌(infineon)合作得板子PSOC 6 板子学习
741 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16998 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-11 20:08 , Processed in 0.947481 second(s), Total 57, Slave 50 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
55