用C++编程实现下面的问题,高手来帮帮忙,谢谢!在线等

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:35:46
为帮助小学生学习乘法,请应用rand生成两个1位整数,程序利用两个整数输出如下问题:6*7=?,然后由学生来计算答案。程序将检查学生的答案。如果正确,输出“Very good!",并提问另一个问题。如果回答错误,程序将输出“NO PLEASE TRY AGAIN."让学生重新计算这个问题,直到答案正确为止。
谢了,哥们,小弟刚学C++,不会啊

#include<iostream>
using namespace std;
int rand(int x)
{
return(++x);
}
void show(int n,int x,int y)
{
if(n==x*y)
{
cout<<"Very good!"<<endl;
}
else
{
cout<<"No,please try again!"<<endl;
cin>>n;
show(n,x,y);
}

}
void main()
{
int i=2,j=3,n;
bool choice=true;
while(choice==true)
{
cout<<rand(i)<<"*"<<rand(j)<<"=";
cin>>n;
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++;
}
}

这是我用C写的,你改成C++就可以了

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#includ