我还不是很擅长这个,我正在尝试学习如何让用户声明的变量在我的方程中工作。现在,我只想让计算机根据用户指定的最大数字吐出一个随机乘法。
当我尝试运行它时,机器会吐出这些错误:
12:16: error: ambiguous overload for 'operator>>' in 'std::cin >> 32767'
14:61: error: 'x' was not declared in this scope
14:64: error: 'y' was not declared in this scope
15:16: error: statement cannot resolve address of overloaded function
20:9: error: declaration of 'int x' shadows a parameter
21:5: error: expected ',' or ';' before 'int
最终目标是计算机将在难度参数范围内生成问题,然后删除方程中的变量之一以对用户进行测验。
#include <cstdlib>
#include <iostream>
using namespace std;
int mult( int x, int y );
int main()
{
cout <<"Please enter a number between 2 and 21, this will determine how difficult your problems are.";
cin >> RAND_MAX;
cin.ignore();
cout << "The product of your numbers is:" << mult ( x, y ) <<"\n";
cin.get;
}
int mult (int x, int y)
{
int x = rand()
int y = rand()
return x * y;
}