代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <iostream>
#include <random>
#include <time.h>
#include <stack>
using namespace std;
#define MAXNUMBER 99
#define MINNUMBER 1
vector<char> operatorUsingList = {'+', '-', 'x', '/', '='};
vector<int> numberList;
string generateFormula()
{
string formulaStr = "";
vector<int> operatorList(numberList.size());
for (int i = 0; i < numberList.size(); i++)
{
numberList[i] = MINNUMBER + rand() % (MAXNUMBER - MINNUMBER + 1);
}
for (int i = 0; i < numberList.size() - 1; i++)
{
operatorList[i] = rand() % (operatorUsingList.size() - 1);
}
operatorList[operatorList.size() - 1] = operatorUsingList.size() - 1;
int result = 0;
for (int i = 0; i < numberList.size(); i++)
{
formulaStr = formulaStr + to_string(numberList[i]) + " " + operatorUsingList[operatorList[i]] + " ";
}
formulaStr += to_string(result);
return formulaStr;
}
int getResult()
{
int result = 0;
while ()
return result;
}
int main()
{
int formulaNum = 0;
int maxNumber = 0;
scanf("%d", &formulaNum);
numberList = vector<int>(3);
srand((unsigned)time(NULL));
for (int i = 0; i < formulaNum; i++)
{
cout << generateFormula() << endl;
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。