谁有好的计算器程序没有 ?
来源:百度知道 编辑:UC知道 时间:2024/07/07 03:07:41
#include <iostream.h>
#include <string>
using namespace std;
/**************Simple Calculator Code*************************
This program is abstracted from <C++ Programming Language>
all the ideas belong to original author
you can study from it
how to use ?
input a line of expression which is ended with ";"
Examples:
you put :
3+(5+6)*(-1+8);
the reult :
80
and you can continue ...
***********************************************************/
enum Token_value{
NAME, NUMBER, END,
PLUS = '+', MINUS = '-',MUL = '*',DIV = '/',
PRINT = ';',ASSIGN = '=',LP = '(',RP = ')'
};
Token_value curr_tok = PRINT;
// fuction list//////////////////////////////////////
double expr(bool get);
double term(bool get);
double prim(bool get);
To