运算 计应192(西) 7组 刘猛

void primary()
{
clean_1();
cout << "即将开始加减法运算" << endl;
srand(int(time(0)));
int i, a, b, sum, sum1, pol, poo = 0, a1, b1, c1;
int oor;
/*
i 循环判断
a、b 加数和被加数
sum 系统计算结果
sum1 人工输入结果
pol 判断加减法
poo 判断是否完成训练
a1、b1、c1 用于记录当前时间
oor 是否继续
*/
//计时器开始
time_t tt = time(NULL);//这句返回的只是一个时间cuo
tm* t = localtime(&tt);
a1 = t->tm_hour; b1 = t->tm_min; c1 = t->tm_sec;
//记录了当前时间
while (1)
{
for (i = 0; i < 20; i++)
{
a = rand() % 10000;
b = rand() % 10000;
pol = rand() % 100;//随机数大于50为加,小于50为减
if (pol < 50)
{
if (a > b)
{
cout << a << '-' << b << '=';
sum = a - b;
cin >> sum1;
if (sum != sum1)
{
cout << "真遗憾!你失败了!请再接再厉!" << endl;
poo++;
break;
}
}
else
{
cout << b << '-' << a << '=';
sum = b - a;
cin >> sum1;
if (sum != sum1)
{
cout << "真遗憾!你失败了!请再接再厉!" << endl;
poo++;
break;
}
}
}
else
{
cout << a << '+' << b << '=';
sum = a + b;
cin >> sum1;
if (sum != sum1)
{
cout << "真遗憾!你失败了!请再接再厉!" << endl;
poo++;
break;
}
}
}
if (poo == 0)
{
time1(a1, b1, c1);
}
cout << "继续请输入1,返回菜单请输入2,其他任意键则退出。" << endl;
cin >> oor;
if (oor == 1)
clean_1();
if (oor == 2)
{
menu();
break;
}
if (oor > 2 || oor == 0)
{
break;
}
}
}

计应192(西)

7组

刘猛

posted @ 2021-04-08 16:18  计应192西七组  阅读(67)  评论(0编辑  收藏  举报