1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 5 #define NUM 1000 6 7 struct VOC 8 { 9 char word[10];//单词 10 char translation[60];// 翻译 11 int whichDay;//哪一天背的 12 int correctNum;//正确次数 13 int wrongNum;//错误次数 14 int passed;//是否通过 15 }voc[NUM]; 16 17 int score[100];//成绩 18 int time=0;//背诵天数 19 20 FILE *vocRead(); 21 FILE *fileRead(int *,int *); 22 void check(int time); 23 void start(); 24 int amounts=100;//测试使用 25 26 int main() 27 { 28 start(); 29 time=1; 30 voc[159].whichDay=1;voc[658].whichDay=1;voc[237].whichDay=1;//进行测试 31 check(time); 32 return 0; 33 } 34 35 FILE *vocRead() 36 { 37 FILE *fp; 38 fp=fopen("百次斩词库.txt","r"); 39 if(fp==0) 40 { 41 printf("文件出错,请检查。"); 42 exit(1); 43 } 44 fscanf(fp,"%s%s",&voc[0].word,&voc[0].translation); 45 for(int i=1;!feof(fp)&&i<NUM;i++) 46 { 47 fscanf(fp,"%s%s",&voc[i].word,&voc[i].translation); 48 } 49 fclose(fp); 50 } 51 //void recite(int time); 52 void check(int time) 53 { 54 int k=0;//检查次数 55 float todayScore[200]; 56 char input[10]; 57 time=1; 58 for(int i=0;i<NUM;i++) 59 { 60 if(voc[i].whichDay==time) 61 { 62 printf("请输入相应的单词:%s ",voc[i].translation); 63 while(1) 64 { 65 if(k==7) 66 { 67 printf(" %s",voc[i].word); 68 break; 69 } 70 scanf("%s",input); 71 if(strcmp(voc[i].word,input)==0) 72 { 73 voc[i].correctNum++; 74 if(voc[i].correctNum>=voc[i].wrongNum) 75 { 76 voc[i].passed=1; 77 todayScore[time]++; 78 break; 79 } 80 printf("输入正确,你真棒!请再次输入:"); 81 } 82 else 83 { 84 printf("输入错误,请重新输入:"); 85 voc[i].wrongNum++; 86 } 87 k++; 88 } 89 } 90 } 91 todayScore[time]=todayScore[time]/amounts; 92 } 93 94 void displayFail(int time) 95 { 96 printf("单词 翻译 "); 97 for(int i=0;i<NUM;i++) 98 { 99 if(voc[i].whichDay==time) 100 { 101 if(voc[i].passed==0) 102 { 103 printf("%s %s ",voc[i].word,voc[i].translation); 104 } 105 } 106 } 107 } 108 109 void start() 110 { 111 printf("**********1.开始背词********** "); 112 printf("********2.设置背诵数量********** "); 113 printf("**********3.检查今天单词********** "); 114 printf("**********1.开始背词********** "); 115 printf("**********1.开始背词********** "); 116 printf("**********1.开始背词********** "); 117 printf("**********1.开始背词********** "); 118 printf("**********1.开始背词********** "); 119 char choice=getchar(); 120 switch(choice) 121 { 122 case '1':; 123 // case '2':settings();break; 124 case '3':check(time); 125 } 126 } 127 128 FILE *fileRead(int *amounts,int *passedScore) 129 { 130 char nothing[30]; 131 FILE *fp; 132 fp=fopen("词库数据管理","r+"); 133 if(fp==0) 134 { 135 printf("文件出错,请检查。"); 136 exit(1); 137 } 138 fscanf(fp,"%s%d%s%d%s",nothing,amounts,nothing,passedScore,nothing); 139 fscanf(fp,"%d%d%d%d",&voc[0].whichDay,&voc[0].correctNum,&voc[0].wrongNum,&voc[0].passed); 140 for(int i=1;!feof(fp)&&i<NUM;i++) 141 { 142 fscanf(fp,"%d%d%d%d",&voc[i].whichDay,&voc[i].correctNum,&voc[i].wrongNum,&voc[i].passed); 143 } 144 fclose(fp); 145 return fp; 146 }