1 Star 0 Fork 0

Faster-dd/learn_software_engineering

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
project1.cpp 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Faster-dd 提交于 2024-07-06 16:54 . add project1's files
#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;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/faster-dd/learn_software_engineering.git
[email protected]:faster-dd/learn_software_engineering.git
faster-dd
learn_software_engineering
learn_software_engineering
master

搜索帮助