写一个简单的背单词c语言程序 | 您所在的位置:网站首页 › return单词讲解 › 写一个简单的背单词c语言程序 |
单词库需要手动添加单词,一共有三个txt文档 文档格式如下 备注:必修严格按照格式来,否者则会显示不准确。 实现功能如下 查询单词:汉语查询英语英语查查询汉语 背诵模式:出现英语默写汉语,出现汉语默写英语 还有 错词背诵模式 查看全部单词 查看全部错词 移除一个错词 等等 全部代码如下: #include #include #include #include void menu(); void beidanci(); void words(); void lookcw(); void search(); void movecc(); void beidancicw(); int k=1; int main() {int w=0; while(k!=0) { menu(); } system("pause"); return 0; } void words() { int i=0; typedef struct stu { int j; char yw[20]; char zw[20]; }dcb; dcb dcb_[1000]; FILE *fp; fp=fopen("D:\\仿真单词本\\dancibenqb.txt","r"); if(!fp) { printf("打开失败!"); exit(1); } fscanf(fp,"%d%s%s",&dcb_[i].j,dcb_[i].yw,dcb_[i].zw); while(!feof(fp)) { i++; fscanf(fp,"%d%s%s",&dcb_[i].j,dcb_[i].yw,dcb_[i].zw); } fclose(fp); dcb_[i+1].j=0; i=0; printf("单词本的信息如下\n"); while((dcb_[i].j)!=0) { printf("%d %s %s\n",dcb_[i].j,dcb_[i].yw,dcb_[i].zw); i++; } system("pause"); } void beidanci() { typedef struct stu { int j; char yw[20]; char zw[20]; }dcb; dcb dcb_[1000]; typedef struct ct { int c; char Cyw[20]; char Czw[20]; }ctb; ctb ctb_[1000]; FILE *fp; int i=0,count=0,q=0; int w=1,count1; char zwsr[20]; fp=fopen("D:\\仿真单词本\\dancibenqb.txt","r"); fscanf(fp,"%d%s%s",&dcb_[i].j,dcb_[i].yw,dcb_[i].zw); while(!feof(fp)) { i++; fscanf(fp,"%d%s%s",&dcb_[i].j,dcb_[i].yw,dcb_[i].zw); } fclose(fp); fp=fopen("D:\\仿真单词本\\dancibencw.txt","r"); fscanf(fp,"%d%s%s",&ctb_[q].c,ctb_[q].Cyw,ctb_[q].Czw); while(!feof(fp)) { q++; fscanf(fp,"%d%s%s",&ctb_[q].c,ctb_[q].Cyw,ctb_[q].Czw); } count1=q; fclose(fp); dcb_[i+1].j=0; int m=0; printf("单词本的信息如下\n"); while((dcb_[m].j)!=0) { printf("%d %s %s\n",dcb_[m].j,dcb_[m].yw,dcb_[m].zw); m++; } count=m; int n; int sjs[50]={0};//随机数 srand(time(NULL)); printf("请选择背单词的模式:\n\n1: 出现英语背诵翻译 \n2: 出现汉字默写英语\n"); int num,p=0; scanf("%d",&num); if(num==1) { printf("请输入背单词的数量"); scanf("%d",&n); for(int i=0;i |
CopyRight 2018-2019 实验室设备网 版权所有 |