|
|
#include<stdio.h>
|
|
|
#include<string.h>
|
|
|
#include<stdlib.h>
|
|
|
#include<time.h>
|
|
|
#define MAX_words 200
|
|
|
typedef struct{
|
|
|
char English[20];
|
|
|
char Chinese[20];
|
|
|
}Word;//结构体储存单词
|
|
|
Word words[MAX_words];//结构体数组名,可调用
|
|
|
int wordCount=0;//记录初始化的单词数
|
|
|
void initWords(){ //初始化函数
|
|
|
const char* p[100][2]={
|
|
|
{"alarm", "警报"},
|
|
|
{"aircraft", "飞机"},
|
|
|
{"air", "空气"},
|
|
|
{"aim", "目标"},
|
|
|
{"aid", "帮助"},
|
|
|
{"ahead", "在前"},
|
|
|
{"agriculture", "农业"},
|
|
|
{"agreement", "协议"},
|
|
|
{"agree", "同意"},
|
|
|
{"ago", "前"},
|
|
|
{"aggressive", "侵略的"},
|
|
|
{"agent", "代理人"},
|
|
|
{"agenda", "议程"},
|
|
|
{"agency", "代理"},
|
|
|
{"age", "年龄"},
|
|
|
{"against", "反对"},
|
|
|
{"again", "再次"},
|
|
|
{"afterword", "之后"},
|
|
|
{"afternoon", "下午"},
|
|
|
{"after", "在...之后"},
|
|
|
{"afraid", "害怕"},
|
|
|
{"afford", "负担得起"},
|
|
|
{"affiliate", "使隶属"},
|
|
|
{"affect", "感情"},
|
|
|
{"affection", "影响"},
|
|
|
{"affair", "事情"},
|
|
|
{"aesthetic", "美学的"},
|
|
|
{"aeroplane", "飞机"},
|
|
|
{"advice", "建议"},
|
|
|
{"advise", "建议"},
|
|
|
{"advertisement", "广告"},
|
|
|
{"advertise", "做广告"},
|
|
|
{"adventurous", "冒险的"},
|
|
|
{"adventure", "冒险"},
|
|
|
{"advantage", "优势"},
|
|
|
{"advanced", "高级的"},
|
|
|
{"advance", "前进"},
|
|
|
{"adult", "成年人"},
|
|
|
{"adore", "崇拜"},
|
|
|
{"adopt", "收养"},
|
|
|
{"adolescent", "青少年"},
|
|
|
{"admit", "承认"},
|
|
|
{"admission", "入场费"},
|
|
|
{"admire", "钦佩"},
|
|
|
{"administrator", "管理员"},
|
|
|
{"administration", "管理"},
|
|
|
{"administer", "管理"},
|
|
|
{"adjustment", "调整"},
|
|
|
{"adjust", "调整"},
|
|
|
{"adequate", "足够的"},
|
|
|
{"address", "地址"},
|
|
|
{"addtional", "附加的"},
|
|
|
{"addtion", "加法"},
|
|
|
{"addict", "使上瘾"},
|
|
|
{"add", "添加"},
|
|
|
{"adapt", "适应"},
|
|
|
{"acute", "尖锐的"},
|
|
|
{"actual", "实际的"},
|
|
|
{"actress", "女演员"},
|
|
|
{"actor", "演员"},
|
|
|
{"activity", "活动"},
|
|
|
{"activist", "活动家"},
|
|
|
{"active", "积极的"},
|
|
|
{"orange", "橙子"},
|
|
|
{"act", "行动"},
|
|
|
{"across", "横过"},
|
|
|
{"acrobat", "杂技演员"},
|
|
|
{"acquire", "获得"},
|
|
|
{"acquaint", "使了解"},
|
|
|
{"acknowledge", "承认"},
|
|
|
{"achievement", "成就"},
|
|
|
{"accustom", "使习惯"},
|
|
|
{"achieve", "实现"},
|
|
|
{"ache", "疼痛"},
|
|
|
{"accumulate", "积累"},
|
|
|
{"any", "任何"},
|
|
|
{"abroad", "国外"},
|
|
|
{"abrupt", "突然的"},
|
|
|
{"absence", "缺席"},
|
|
|
{"absorb", "吸收"},
|
|
|
{"abstract", "抽象的"},
|
|
|
{"absurd", "荒谬的"},
|
|
|
{"abundance", "丰富"},
|
|
|
{"abundant", "丰富的"},
|
|
|
{"abuse", "滥用"},
|
|
|
{"academic", "学术的"},
|
|
|
{"academy", "学院"},
|
|
|
{"accelerate", "加速"},
|
|
|
{"accent", "口音"},
|
|
|
{"accept", "接受"},
|
|
|
{"accident", "意外"},
|
|
|
{"accompany", "陪伴"},
|
|
|
{"accomplish", "完成"},
|
|
|
{"accord", "使一致"},
|
|
|
{"accordance", "一致"},
|
|
|
{"according", "根据"},
|
|
|
{"ambition", "雄心"},
|
|
|
{"amuse", "娱乐"},
|
|
|
{"ancestor", "祖先"},
|
|
|
{"ancient", "古代的"}
|
|
|
};
|
|
|
int i;
|
|
|
for(i=0;i<100;i++){
|
|
|
strcpy(words[i].English,p[i][0]); //将单词存入结构体数组
|
|
|
strcpy(words[i].Chinese,p[i][1]); //将中文存入结构体数组
|
|
|
wordCount++;
|
|
|
}
|
|
|
}
|
|
|
void praise(){
|
|
|
int k;
|
|
|
srand(time(NULL));
|
|
|
k=rand()%5+1;
|
|
|
switch(k){
|
|
|
case 1:printf("Good job!\n");
|
|
|
break;
|
|
|
case 2:printf("Well done!\n");
|
|
|
break;
|
|
|
case 3:printf("Way to go!\n");
|
|
|
break;
|
|
|
case 4:printf("Perfect!\n");
|
|
|
break;
|
|
|
case 5:printf("Great!\n");
|
|
|
}
|
|
|
}
|
|
|
int settingNumber(){
|
|
|
int number;
|
|
|
printf("请选择你想背单词的个数(1到100)\n");
|
|
|
scanf("%d",&number);
|
|
|
return number;
|
|
|
|
|
|
}
|
|
|
void wordsentery(){
|
|
|
printf("请输入你想要添加的单词:");
|
|
|
scanf("%s",words[wordCount].English);
|
|
|
printf("请输入它的中文意思:");
|
|
|
scanf("%s",words[wordCount].Chinese);
|
|
|
wordCount++;
|
|
|
system("pause");
|
|
|
system("cls");
|
|
|
}
|
|
|
int menu(){
|
|
|
int select;
|
|
|
printf("************************************\n");
|
|
|
printf("*********欢迎使用背单词系统*********\n");
|
|
|
printf("************************************\n");
|
|
|
printf("****\t[1]普通背单词 ****\n");
|
|
|
printf("****\t[2]查看往次背诵成绩 ****\n");
|
|
|
printf("****\t[3]趣味背单词 ****\n");
|
|
|
printf("****\t[0]退出程序 ****\n");
|
|
|
printf("************************************\n");
|
|
|
printf("请输入选项>");
|
|
|
scanf("%d",&select);
|
|
|
return select;
|
|
|
}
|
|
|
typedef struct grade{
|
|
|
time_t stim;
|
|
|
int socer;
|
|
|
}grade;
|
|
|
typedef struct node{
|
|
|
grade date;
|
|
|
struct node*next;
|
|
|
}Node;
|
|
|
typedef struct List{
|
|
|
Node* front;
|
|
|
int size;
|
|
|
}List;
|
|
|
void entryRecord(List*list,int sc){
|
|
|
Node *node =(Node*)malloc(sizeof(Node));
|
|
|
if(!node){
|
|
|
printf("malloc failed\n");
|
|
|
}
|
|
|
node->next=NULL;
|
|
|
time(&node->date.stim);
|
|
|
node->date.socer=sc;
|
|
|
if(list->front==NULL){
|
|
|
list->front=node;
|
|
|
}else{
|
|
|
Node*lastNode;
|
|
|
lastNode=list->front;
|
|
|
while(lastNode->next!=NULL){
|
|
|
lastNode=lastNode->next;
|
|
|
}
|
|
|
lastNode->next=node;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
void saveRecord(List*list){
|
|
|
FILE*fp=fopen("record.txt","a");
|
|
|
if(!fp){
|
|
|
perror("file open failed");
|
|
|
return;
|
|
|
}
|
|
|
Node*movenode=list->front;
|
|
|
while(movenode!=NULL){
|
|
|
fprintf(fp,"时间:%s 成绩:%d\n",ctime(&movenode->date.stim),movenode->date.socer);
|
|
|
movenode=movenode->next;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
void readAndPrintFile(const char *filename) {
|
|
|
FILE *fp;
|
|
|
char ch;
|
|
|
|
|
|
fp = fopen(filename, "r");
|
|
|
if (fp == NULL) {
|
|
|
printf("无法打开文件: %s\n", filename);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
while ((ch = fgetc(fp))!= EOF) {
|
|
|
putchar(ch);
|
|
|
}
|
|
|
|
|
|
fclose(fp);
|
|
|
}
|
|
|
void BaiWords(Word words[],List*list){
|
|
|
int score,n,m;float cnt;
|
|
|
srand(time(NULL));
|
|
|
printf("请选择类型:1 给中输英 2 给英输中\n");
|
|
|
scanf("%d",&m);
|
|
|
switch(m){
|
|
|
case 1 :
|
|
|
score=0;cnt=0;
|
|
|
printf("请选择你的答题数量\n");
|
|
|
do{
|
|
|
scanf("%d",&n);
|
|
|
if(n<0||n>100)printf("输入范围错误,请重新输入!");
|
|
|
}while(n<0||n>100);
|
|
|
for(int i=0;i<n;i++){
|
|
|
int randomIndex=rand()%100;
|
|
|
printf("%s的英文是什么?(中途退出输入x)",words[randomIndex].Chinese);
|
|
|
char answer[50];
|
|
|
scanf("%s",answer);
|
|
|
if(strcmp(answer,"x")==0)return;
|
|
|
if(strcmp(answer,words[randomIndex].English)==0){
|
|
|
praise();
|
|
|
printf("回答正确!加%d分!\n",100/n);
|
|
|
score+=100/n;
|
|
|
cnt++;
|
|
|
}else{
|
|
|
printf("回答错误,正确答案为: %s\n",words[randomIndex].English);
|
|
|
}
|
|
|
}
|
|
|
cnt/=n;
|
|
|
printf("你的得分为%d 你的正确率为%.2f\n",score,cnt);
|
|
|
break;
|
|
|
case 2:
|
|
|
score=0;cnt=0;
|
|
|
printf("请选择你的答题数量(1到100)\n");
|
|
|
do{
|
|
|
scanf("%d",&n);
|
|
|
if(n<0||n>100)printf("输入范围错误,请重新输入!");
|
|
|
}while(n<0||n>100);
|
|
|
for(int i=0;i<n;i++){
|
|
|
int randomIndex=rand()%100;
|
|
|
printf("%s的中文是什么?(中途退出输入x)",words[randomIndex].English);
|
|
|
char answer[50];
|
|
|
scanf("%s",answer);
|
|
|
if(strcmp(answer,"x")==0)return;
|
|
|
if(strcmp(answer,words[randomIndex].Chinese)==0){
|
|
|
printf("回答正确!加%d分!\n",100/n);
|
|
|
score+=10;
|
|
|
cnt++;
|
|
|
}else{
|
|
|
printf("回答错误,正确答案为: %s\n",words[randomIndex].Chinese);
|
|
|
}
|
|
|
}
|
|
|
cnt/=n;
|
|
|
printf("你的得分为%d 你的正确率为%.2f\n",score,cnt);
|
|
|
break;
|
|
|
}
|
|
|
entryRecord(list,score);
|
|
|
saveRecord(list);
|
|
|
}
|
|
|
void Funmemorize(int c1,List*list){
|
|
|
|
|
|
struct danci{
|
|
|
int j;
|
|
|
char px[50];
|
|
|
char zw[50];
|
|
|
};
|
|
|
typedef struct danci danStru;
|
|
|
|
|
|
danStru dcsj[100] = {
|
|
|
{1,"alarm", "警报"},
|
|
|
{2,"aircraft", "飞机"},
|
|
|
{3,"air", "空气"},
|
|
|
{4,"aim", "目标"},
|
|
|
{5,"aid", "帮助"},
|
|
|
{6,"ahead", "在前"},
|
|
|
{7,"agriculture", "农业"},
|
|
|
{8,"agreement", "协议"},
|
|
|
{9,"agree", "同意"},
|
|
|
{10,"ago", "前"},
|
|
|
{11,"aggressive", "侵略的"},
|
|
|
{12,"agent", "代理人"},
|
|
|
{13,"agenda", "议程"},
|
|
|
{14,"agency", "代理"},
|
|
|
{15,"age", "年龄"},
|
|
|
{16,"against", "反对"},
|
|
|
{17,"again", "再次"},
|
|
|
{18,"afterword", "之后"},
|
|
|
{19,"afternoon", "下午"},
|
|
|
{20,"after", "在...之后"},
|
|
|
{21,"afraid", "害怕"},
|
|
|
{22,"afford", "负担得起"},
|
|
|
{23,"affiliate", "使隶属"},
|
|
|
{14,"affect", "感情"},
|
|
|
{25,"affection", "影响"},
|
|
|
{26,"affair", "事情"},
|
|
|
{27,"aesthetic", "美学的"},
|
|
|
{28,"aeroplane", "飞机"},
|
|
|
{29,"advice", "建议"},
|
|
|
{30,"advise", "建议"},
|
|
|
{31,"advertisement", "广告"},
|
|
|
{32,"advertise", "做广告"},
|
|
|
{33,"adventurous", "冒险的"},
|
|
|
{34,"adventure", "冒险"},
|
|
|
{35,"advantage", "优势"},
|
|
|
{36,"advanced", "高级的"},
|
|
|
{37,"advance", "前进"},
|
|
|
{38,"adult", "成年人"},
|
|
|
{39,"adore", "崇拜"},
|
|
|
{40,"adopt", "收养"},
|
|
|
{41,"adolescent", "青少年"},
|
|
|
{42,"admit", "承认"},
|
|
|
{43,"admission", "入场费"},
|
|
|
{44,"admire", "钦佩"},
|
|
|
{45,"administrator", "管理员"},
|
|
|
{46,"administration", "管理"},
|
|
|
{47,"administer", "管理"},
|
|
|
{48,"adjustment", "调整"},
|
|
|
{49,"adjust", "调整"},
|
|
|
{50,"adequate", "足够的"},
|
|
|
{51,"address", "地址"},
|
|
|
{52,"addtional", "附加的"},
|
|
|
{53,"addtion", "加法"},
|
|
|
{54,"addict", "使上瘾"},
|
|
|
{55,"add", "添加"},
|
|
|
{56,"adapt", "适应"},
|
|
|
{57,"acute", "尖锐的"},
|
|
|
{58,"actual", "实际的"},
|
|
|
{59,"actress", "女演员"},
|
|
|
{60,"actor", "演员"},
|
|
|
{61,"activity", "活动"},
|
|
|
{62,"activist", "活动家"},
|
|
|
{63,"active", "积极的"},
|
|
|
{64,"orange", "橙子"},
|
|
|
{65,"act", "行动"},
|
|
|
{66,"across", "横过"},
|
|
|
{67,"acrobat", "杂技演员"},
|
|
|
{68,"acquire", "获得"},
|
|
|
{69,"acquaint", "使了解"},
|
|
|
{70,"acknowledge", "承认"},
|
|
|
{71,"achievement", "成就"},
|
|
|
{72,"accustom", "使习惯"},
|
|
|
{73,"achieve", "实现"},
|
|
|
{74,"ache", "疼痛"},
|
|
|
{75,"accumulate", "积累"},
|
|
|
{76,"any", "任何"},
|
|
|
{77,"abroad", "国外"},
|
|
|
{78,"abrupt", "突然的"},
|
|
|
{79,"absence", "缺席"},
|
|
|
{80,"absorb", "吸收"},
|
|
|
{81,"abstract", "抽象的"},
|
|
|
{82,"absurd", "荒谬的"},
|
|
|
{83,"abundance", "丰富"},
|
|
|
{84,"abundant", "丰富的"},
|
|
|
{85,"abuse", "滥用"},
|
|
|
{86,"academic", "学术的"},
|
|
|
{87,"academy", "学院"},
|
|
|
{88,"accelerate", "加速"},
|
|
|
{89,"accent", "口音"},
|
|
|
{90,"accept", "接受"},
|
|
|
{91,"accident", "意外"},
|
|
|
{92,"accompany", "陪伴"},
|
|
|
{93,"accomplish", "完成"},
|
|
|
{94,"accord", "使一致"},
|
|
|
{95,"accordance", "一致"},
|
|
|
{96,"according", "根据"},
|
|
|
{97,"ambition", "雄心"},
|
|
|
{98,"amuse", "娱乐"},
|
|
|
{99,"ancestor", "祖先"},
|
|
|
{100,"ancient", "古代的"}
|
|
|
};
|
|
|
printf("1.进入单词预览\n2.进入单词学习\n"); //显示过程
|
|
|
printf("----------------------------------------\n");
|
|
|
int i=0;
|
|
|
printf("***进行单词预览***\n");
|
|
|
while(i < 99) //输出用于存储单词信息的结构体的内容
|
|
|
{
|
|
|
printf("%d %s %s\n",dcsj[i].j,dcsj[i].px,dcsj[i].zw);
|
|
|
i++;
|
|
|
}
|
|
|
printf("----------------------------------------\n");
|
|
|
printf("单词预览结束,系统会随机选择背诵的单词\n按任意建(除空格)进入单词学习!");
|
|
|
char dy;
|
|
|
scanf(" %c", &dy); //将用户输入的任意内容存储到字符变量里,并执行下一步
|
|
|
if(dy != ' '){
|
|
|
system("cls"); //清屏
|
|
|
}
|
|
|
printf("***进入单词学习***\n");
|
|
|
int sjs1[99], sjs2[99], sjs3[99], count = 99; // "count"为单词总数
|
|
|
srand(time(NULL)); //产生随机数,用于确定用户需背的单词
|
|
|
for(i=0;i<c1;i++) //随机数总数为用户想背的单词数“c1”
|
|
|
{
|
|
|
sjs1[i] = rand()%count + 1; //“count”为单词总数
|
|
|
}
|
|
|
|
|
|
struct cuoti{//创建一个错题本
|
|
|
int j;
|
|
|
char px[50];
|
|
|
char zw[50];
|
|
|
};
|
|
|
typedef struct cuoti cuoStru;
|
|
|
cuoStru ct[99];
|
|
|
|
|
|
int b1, score=0, h=0;
|
|
|
for(b1=0;b1<c1;b1++) //进行c1次循环,共背c1个单词
|
|
|
{
|
|
|
do{
|
|
|
for(i=0;i<3;i++)
|
|
|
{
|
|
|
sjs2[i]=rand()%count+1; //产生3个随机数,用于确定每次背诵的干扰选项
|
|
|
}
|
|
|
}while(sjs2[0]==sjs2[1]||sjs2[0]==sjs2[2]||sjs2[0]==sjs1[b1]||sjs2[1]
|
|
|
==sjs2[2]||sjs2[1]==sjs1[b1]||sjs2[2]==sjs1[b1]);
|
|
|
//若四个选项中的单词有重复,则重新执行此步骤,直至四个选项内无重复单词
|
|
|
do{
|
|
|
for(int j=0;j<4;j++)
|
|
|
{
|
|
|
sjs3[j]=rand()%4+1; //产生[1-4]四个随机数,用于随机确定正确选项
|
|
|
}
|
|
|
}while(sjs3[0]==sjs3[1]||sjs3[0]==sjs3[2]||sjs3[0]==sjs3[3]||sjs3[1]
|
|
|
==sjs3[2]||sjs3[1]==sjs3[3]||sjs3[2]==sjs3[3]);
|
|
|
//确保数组内的随机数没有重复
|
|
|
|
|
|
struct cunxuanxiang{
|
|
|
char zw[50];
|
|
|
};
|
|
|
typedef struct cunxuanxiang cunStru;
|
|
|
cunStru dadj[4];
|
|
|
|
|
|
strcpy(dadj[sjs3[0]-1].zw,dcsj[sjs2[0]].zw); //将干扰项及正确答案复制到dadj数组中
|
|
|
strcpy(dadj[sjs3[1]-1].zw,dcsj[sjs1[b1]].zw);//dadj[sjs3[1]-1]固定为正确选项
|
|
|
strcpy(dadj[sjs3[2]-1].zw,dcsj[sjs2[1]].zw);
|
|
|
strcpy(dadj[sjs3[3]-1].zw,dcsj[sjs2[2]].zw);
|
|
|
|
|
|
printf("单词:\t%s\n选项:\nA.\t%s\nB.\t%s\nC.\t%s\nD.\t%s\n请输入您的选项(A/B/C/D)(中途退出输入x):\t",
|
|
|
dcsj[sjs1[b1]].px,dadj[0].zw,dadj[1].zw,dadj[2].zw,dadj[3].zw);
|
|
|
//将单词及选项输出,引导用户进行选择
|
|
|
|
|
|
int t=sjs3[1]-1;//用于确定此次循环正确选项在数组中的位置
|
|
|
char zq;
|
|
|
switch(t) //用于确定此次循环正确选项对应的选择(A/B/C/D)
|
|
|
{
|
|
|
case 0:zq='A';break;
|
|
|
case 1:zq='B';break;
|
|
|
case 2:zq='C';break;
|
|
|
case 3:zq='D';break;
|
|
|
}
|
|
|
|
|
|
char yhxz;
|
|
|
scanf("%s",&yhxz); //将用户输入的选项存储到字符变量中
|
|
|
if(yhxz=='x')return;
|
|
|
if(yhxz != zq) //判断此次用户是否选择正确
|
|
|
{
|
|
|
printf("背诵错误,已计入错题本!\n");
|
|
|
ct[h].j = dcsj[sjs1[b1]].j; //若用户输入错误,则将该单词存入错题本
|
|
|
strcpy(ct[h].px,dcsj[sjs1[b1]].px);
|
|
|
strcpy(ct[h].zw,dcsj[sjs1[b1]].zw);
|
|
|
h++; //错题本数组指针移动
|
|
|
}
|
|
|
else
|
|
|
{ praise();
|
|
|
printf("背诵正确,请继续答题!\n");
|
|
|
score+=100/c1; //若用户选择正确,则得分“+10”
|
|
|
}
|
|
|
}
|
|
|
printf("错题如下:\n"); //当用户单词全部背诵完毕时,输出错题本及总得分
|
|
|
printf("----------------------------------------\n");
|
|
|
for(i=0;i<h;i++)
|
|
|
{
|
|
|
printf("%d %s %s\n",ct[i].j,ct[i].px,ct[i].zw);
|
|
|
}
|
|
|
printf("----------------------------------------\n");
|
|
|
printf("您错误的题数为: %d\n您的得分为:%d\n",h,score);
|
|
|
entryRecord(list,score);
|
|
|
saveRecord(list);
|
|
|
}
|