#include <iostream>
#include <ctime>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
using namespace std;
inline int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int main()
{
char ch = 'N';
int score = 0;
do
{
srand(time(0));
sleep(1);
int x = rand();
srand(time(0)*time(0)*time(0)+83475*time(0)+985);
sleep(1);
int y = rand();
srand(time(0)*time(0)+4758945*time(0)+1);
sleep(1);
int z = rand() % 4;
if(z == 0)
{
printf("%d+%d=%c\n", x, y, '?');
int a;
cin>>a;
if(a==x+y)
{
printf("√\n");
score ++;
}
else
{
printf("×\n");
}
}
else if(z == 1)
{
printf("%d-%d=%c\n", x, y, '?');
int a;
cin>>a;
if(a==x-y)
{
printf("√\n");
score ++;
}
else
{
printf("×\n");
}
}
else if(x == 2)
{
printf("%d*%d=%c\n", x, y, '?');
int a;
cin>>a;
if(a==x*y)
{
printf("√\n");
score ++;
}
else
{
printf("×\n");
}
}
else
{
printf("%d/%d=%c\n", x, y, '?');
int a;
cin>>a;
if(a==x/y)
{
printf("√\n");
score ++;
}
else
{
printf("×\n");
}
}
printf("score=%d\n", score);
sleep(2);
system("cls");
}while(getchar() != EOF);
printf("得分:!score=%d\n", score);
return 0;
}
猜数字小游戏升级
最新推荐文章于 2024-04-14 21:25:35 发布