一个非常简单的题
2008-03-08 12:51:08 来源:WEB开发网 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁炬儳缍婇弻鐔兼⒒鐎靛壊妲紒鎯у⒔閹虫捇鈥旈崘顏佸亾閿濆簼绨绘い鎺嬪灪閵囧嫰骞囬姣挎捇鏌熸笟鍨妞ゎ偅绮撳畷鍗炍旈埀顒勭嵁婵犲嫮纾介柛灞捐壘閳ь剛鎳撻~婵嬪Ω閳轰胶鐤呯紓浣割儐椤戞瑩宕ョ€n喗鐓曟い鎰靛亝缁舵氨绱撻崘鈺傜婵﹤顭峰畷鎺戔枎閹搭厽袦婵犵數濮崑鎾绘⒑椤掆偓缁夌敻骞嗛悙鍝勭婵烇綆鍓欐俊鑲╃磼閹邦収娈滈柡灞糕偓鎰佸悑閹肩补鈧尙鏁栧┑鐐村灦閹稿摜绮旈悽绋课﹂柛鏇ㄥ灠閸愨偓濡炪倖鍔﹀鈧繛宀婁邯濮婅櫣绱掑Ο璇茶敿闂佺ǹ娴烽弫璇差嚕婵犳碍鏅插璺猴工瀹撳棝姊虹紒妯哄缂佷焦鎸冲畷鎴﹀箻鐠囧弶宓嶅銈嗘尰缁嬫垶绂嶉悙顒佸弿婵☆垳鍘ф禍楣冩倵濮樼偓瀚�

核心提示:/*使用方法可以建立英语库,每次可建立100个单词*/#include <io.h>#include <stdio.h>#include <stdlib.h>#include <time.h>typedef strUCt{ char cha[50]; char eng[5
/*使用方法可以建立英语库,每次可建立100个单词*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef strUCt
{
char cha[50];
char eng[50];
}CTOE;
void writefile();
void PRacticec();
int main()
{
char id;
FILE *fp;
if((fp=fopen("g:\\ctoe.txt","r"))==NULL)/*检测文件是否成在如无文件测建立*/
{
printf("not file!");
clrscr();
writefile();/*建立函数*/
}
do
{
clrscr();
printf(" __________________________________\n");
printf(" 0.建立英语库 1.进入练习 2.退出 \n");
printf("__________________________________\n");
id=getch();
switch(id)
{
case '0':writefile(); break;/*建立文件*/
case '1':practicec(); break;/*进入测试题*/
}
}while(id!='2');
fclose(fp);
}
void writefile()
{
CTOE ctoe[100];
FILE *fp;
int i,count=0;
do
{
printf("%dinput china:",count+1);
scanf("%s",ctoe[count].cha);
printf("%dinput english:",count+1);
scanf("%s",ctoe[count].eng);
count++;
}while(count<100);
fp=fopen("g:\\ctoe.txt","w");
for(i=0; i<count; i++)
fprintf(fp,"%s %s\n",ctoe[i].cha,ctoe[i].eng);
fclose(fp);
}
void practicec()
{
CTOE ctoe[100];
char ieng[20];
int num=100,rn=0,orn,grade=30;
int score=0;
FILE *fp;
int i;
fp=fopen("g:\\ctoe.txt","r");
for(i=0; i<100; i++)
fscanf(fp,"%s %s",ctoe[i].cha,ctoe[i].eng);
do
{
for(i=0; i<grade; i++)
{
do
{
orn=rn;
rn=random(num);
}while(rn==orn);
printf("%d\t%s\n",i,ctoe[rn].cha);
printf("请翻译单词:");
scanf("%s",ieng);
if(strcmp(ieng,ctoe[rn].eng))
{
printf("错误正确的应是:%s\n",ctoe[rn].eng);
}
else
{
printf("您答对了请继续!\n");
score+=1;
}
}
if(score>=grade-1)/*判定是否合格合格进入下一级*/
{
grade+=10;
clrscr();
printf("非常好您过关了按任意键进入下一级!");
clrscr();
getch();
}
else { grade=0;
clrscr();
printf("真不幸您没有过关!");
}
}while(grade);
fclose(fp);
getch();
}
更多精彩
赞助商链接