C++实现简易计算器:2 * 123
不多说 上代码
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream> // 解决cin不录入空格问题
#include <conio.h> // 获取键盘点击事件
using namespace std;
class Calculator {
public:
string operatorList;
Calculator();
string formatString(string str) {
string newStr = str;
while (1)
{
if (newStr.find(" ", 0) > str.size()) {
break;
}
int spaceIndex = newStr.find(" ", 0);
newStr = newStr.erase(spaceIndex