```/* 包含头文件 /
using namespace std;
int CreatingExpression(int & a, int &b, char &op) ;
bool ValidatingUserAnswer(int a, int b, char op, int answer) ;
/函数功能:对两整型数进行加、减、乘、除四则运算
函数参数: 整型变量a、b分别表示参加运算的两个操作数
整型变量op表示运算类型
函数返回值:当用户输入的答案与结果相同时,返回值为 1,
否则返回值为 0
*/
程序模板
int main()
{
const int NUMBER = 10; //出题总数为10
// 设置随机数种子
//调用其它函数完成程序
//to do
//cout << "you got "<<right_answer * 10<<" scores, you made "<<10-right_answer<<" mistakes.";
//to do
}
/*加入返回值类型*/ CreatingExpression ( /*加入参数声明*/ )
{
int int_op = 0;
const int LARGEST = 10; // 操作数的最大值
// 在此加入生成1~ LARGEST之间的随机数 a 的代码;
// 在此加入生成 1~ LARGEST之间的随机数 b 的代码;
// 在此加入生成1~4之间的随机数 int_op 的代码;
switch(int_op)
{
case 1:
op = '+';
answer = a+b;
break;
case 2:
op = ‘-’ ;
/* 在此加入处理 a=0; */
//to do others;
case 3:
op = '*';
// to do
case 4:
op = '/';
/* 在此加入处理 除数b == 0 或者 a不能被b整除情况的代码 */
// to do others
}
// 返回答案
}
/*加入返回值类型*/ ValidatingUserAnswer ( /* 加入参数声明 */ )
{
//请使用下面的输出语句输出信息
// cout << a <<op<<b <<"=";
//cout<<"Right!" <<endl;
//cout<<"Not correct!"<<endl;
//to do
//返回值
}