Files
2025-07-01 16:04:35 +08:00

30 lines
554 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include<string>
#include "Calc.h"
using namespace std;
int main() {
string input;
cout << "科学计算器 (输入 q 退出)\n";
while (true) {
cout << "表达式 > ";
getline(cin, input);
if (input == "q" || input == "quit")
break;
double result;
if (Calc::safeEval(input, result)) {
cout << "= " << result << endl;
}
else {
cout << "[错误] 表达式无法计算\n";
}
}
cout << "感谢使用,再见!" << endl;
return 0;
}