急求一个用VC++编写的计算器源代码。有“+,- ,*,/ ”就可以了。万分感谢。。。

来源:百度知道 编辑:UC知道 时间:2024/05/30 05:46:39
如果有界面支持,最好了。。。

#include <iostream>
#include <string>
#include <map>
#include <cctype>
using namespace std;
enum Token_value{
NAME, NUMBER, END,
PLUS='+',MINUS='-',MUL='*',DIV='/',
PRINT=';',ASSIGN='=',LP='(',RP=')'
};
Token_value curr_tok=PRINT;
map<string,double>table;
double term(bool);
double prim(bool);
Token_value get_token();

int no_of_errors;
double error(const string& s)
{
no_of_errors++;
cerr << "error:" << s << '\n';
return 1;
}

double expr(bool get)
{
double left = term(get);
for(;;)
switch(curr_tok){
case PLUS:
left+=term(true);
break;
case MINUS