
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
int a = rand() % 10;
int b = rand() % 10;
bool flag = false;
cout << "How much is " << a << " times " << b << "?\n";
while (true)
{
if (flag)
{
a = rand() % 10;
b = rand() % 10;
cout << "How much is " << a << " times " << b << "?\n";
}
int res;
cin >> res;
if (res == a * b)
{
cout << "very good\n";
flag = true;
}
else
{
cout << "No,try again\n";
flag = false;
}
}
return 0;
}
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0));
int a = rand() % 10, b = rand() % 10, c;
cout << "How much is " << a << " times " << b << "?" << endl;
while (1) {
cin >> c;
if (a * b != c)
cout << "No,try again" << endl;
else {
cout << "very good";
break;
}
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
srand((int)time(0));
while(1) {
int a=rand()%10,b=rand()%10;
while(1) {
printf("how much is %d times %d?\n",a,b);
int ans;
cin>>ans;
if(ans!=a*b) cout<<"No,try again!\n";
else {
cout<<"Very good!\n";
break;
}
}
}
return 0;
}