#include void OpenWordFile(char string[200][12]);
void PlayGame(char wordlist[200][12]);
void Change(char wordlist[200][12],char str[200][12]);
void StartGame (char wordlist[200][12]);
int round;
void Set()
{
printf("请输入您想猜的单词数:");
scanf("%d",&round);
}
struct Player
{
char name[20];
int right;
int wrong;
int time;
};
typedef struct Player Player;
Player p[5]={{1,"unknown",0,0,0},{2,"unknown",0,0,0},{3,"unknown",0,0,0},{4,"unknown",0,0,0},{5,"unknown",0,0,0}};
Player temp;
int right=0,wrong=0;
int times;
class ByTime
{
private:
clock_t start;
public:
ByTime()
{
start=clock();
}
~ByTime(){};
void Endtime()
{
clock_t end;
end=clock();
times=(end-start)/CLOCKS_PER_SEC;
cout
y=x;
else
k++;
c=strcmp(guessword,wordlist[q]);
}
if(c==0){
printf("\nHow smart you are! 你成功猜出了这个单词!\n正确单词就是:%s",wordlist[q]);
right++;
}
if(c!=0)
{
printf("\nSorry... 你已经超过了规定的次数,挑战失败了...\n正确单词是:%s",wordlist[q]);
wrong++;
}
printf("你猜对了%d个字母,猜错了%d个字母。\n",x,k-1);
WrongGuess[t] = '\0';
printf("错误字母分别是%s\n",WrongGuess);
}
void Change (char wordlist[200][12],char str[200][12])
{
int i,j;
for(i=0;i<200;i++){
for(j=0;j<12;j++){
wordlist[i][j]=str[i][j];
}
}
}
void Input()
{
printf("请先输入您的大名:");
scanf("%s",temp.name);
}
void Result()
{
temp.right=right;
temp.wrong=wrong;
}
void Time()
{
temp.time=times;
}
void Compare()
{
int i,j,k;
for(i=0;i<6;i++){
if(temp.right>p[i].right) {
for(j=5;j>i;j--){
for(k=0;k<20;k++){
p[j].name[k]=p[j-1].name[k];
}
p[j].right=p[j-1].right;
p[j].wrong=p[j-1].wrong;
p[j].time=p[j-1].time;
}
for(k=0;k<20;k++){
p[i].name[k]=temp.name[k];
}
p[i].right=temp.right;
p[i].wrong=temp.wrong;
p[i].time=temp.time;
break;
}
}
}
void Record()
{
int i;
FILE *fp;
fp=fopen("record.txt","r+");
if(!fp)
{
printf("游戏记录无法打开!");
exit(1);
}
fprintf(fp,"名次\t姓名\t\t成绩:猜对 or 猜错)\t时间(s)\n");
for(i=0;i<5;i++){
fprintf(fp,"%d\t%s\t\tRight:%d Wrong:%d\t%d\n",i+1,p[i].name,p[i].right,p[i].wrong,p[i].time);
}
fclose(fp);
}
void Show()
{
int i;
FILE *fp;
fp=fopen("record.txt","r");
if(!fp)
{
printf("游戏记录无法打开!\n");
exit(1);
}
fprintf(stdout,"名次\t姓名\t\t成绩(猜对 猜错)\t时间(s)\n");
for(i=0;i<5;i++){
fprintf(stdout,"%d\t%s\t\tRight:%d Wrong:%d\t%d\n",i+1,p[i].name,p[i].right,p[i].wrong,p[i].time);
}
fclose(fp);
}
void StartGame (char wordlist[200][12])
{
int p=1;
while(p)
{
int i;
char play;
ByTime t;
for(i=0;i>>>>>>>>> 1. 开始游戏 <<<<<<<<<>>>>>>>>> 2. 设置游戏 <<<<<<<<<>>>>>>>>> 3. 成绩排行 <<<<<<<<<>>>>>>>>> 4. 退出游戏 <<<<<<<<<4)
{
printf("Please choice 1--4 again\n");
scanf("%d",&choice);
}
switch (choice)//选择
{
case 1:
Set();
Input();
StartGame (wordlist);//调用游戏函数
break;
case 2:
SetGame ();//调用设置函数
Set();
Input();
StartGame (wordlist);
break;
case 3:
Show();
break;
case 4:
exit(0);
}
}
28