#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
void jm() {
printf("\n");
printf(" **************\n");
printf(" 开始猜单词游戏\n");
printf(" **************\n");
printf(" 1.开始 2.退出\n");
}
void change(char a[100],char b[100]) {
int d, f;
char t;
for (int i = 0;i < strlen(a);i++) {
d = rand() % (strlen(a));
f = rand() % (strlen(a));
t = a[f];
a[f] = a[d];
a[d] = t;
}
}
int jg(int pd) {
int score=0;
if (pd == 0) {
printf("right\n");
score++;
printf("目前得分:%d\n", score);
}
if (pd != 0) {
printf("wrong\n");
score--;
printf("目前得分:%d\n", score);
}
return score;
}
int main()
{
int x,n;
int score ;
FILE *fp = NULL;
char a[100], b[100], c[100];
fp = fopen("C:\\Users\\噢噢噢\\Desktop\\word.txt", "r");
if (fp == NULL) {
printf("open error\n");
return -1;
}
jm();
scanf("%d", &x);
if (x == 1) {
Sleep(200);
system("CLS");
for (int i = 0;i <= 50;i++) {
printf(" ");
printf(" %d", 2 * i);
printf("\b\b");
Sleep(50);
}
printf("请输入你想猜多少单词:");
scanf("%d", &n);
while (fgets(a, 30, fp)&&n>0) {
int pd = 0;
a[strlen(a) - 1] = '\0';
strcpy(b, a);
change(a, b);
printf("请猜下这个单词原型:%s\n", a);
scanf("%s", c);
pd = strcmp(b, c);
score=jg(pd);
n--;
}
printf("最终得分为:%d", score);
fclose(fp);
}
else if (x == 0)
return 0;