这是我用C写的,你改成C++就可以了
#include
#include
#include
#include
void main ()
{
int m,n,x;
char reply;
srand ((unsigned)time(NULL));
do
{
m=rand()%10;
n=rand()%10;
printf ("please input the answer:\n");
do
{
printf ("%d*",m);
printf ("%d=",n);
scanf ("%d",&x);
if (x==m*n)
{
printf ("You are right!\n");
}
else
printf ("You are wrong!Please try again!\n");
}while (x!=m*n);
printf ("Answer another question? (y/n or Y/N)");
reply=getche();
printf ("\n");
}while(reply=='y'||reply=='Y');
printf ("over\n");
}
#include
using namespace std;
int rand(int x)
{
return(++x);
}
void show(int n,int x,int y)
{
if(n==x*y)
{
cout<<"Very good!"<
else
{
cout<<"No,please try again!"<
show(n,x,y);
}
}
void main()
{
int i=2,j=3,n;
bool choice=true;
while(choice==true)
{
cout<
show(n,rand(i),rand(j));
cout<<"answer another qestion?(Y/N)";
char ch;
cin>>ch;
if(ch=='Y'||ch=='y') choice=true;
else if(ch=='N'||ch=='n') choice=false;
i++;j++;
}
}
#include
#include
using namespace std;
int main()
{
srand((unsigned)time(NULL));
int x=rand()%10;
int y=rand()%10;
int result=x*y;
do
{
int n;
cout<
if(n==result)
{
cout<<"Very good!"<
}
else cout<<"NO PLEASE TRY AGAIN"<
return 0;
}