科学计算器如何用C程序……

来源:百度知道 编辑:UC知道 时间:2024/06/03 04:38:18
进行科学运算很麻烦
怎么样用C语言编写一个科学计算器呢?
(运算类型:+ - * / 乘方 括号)
样例输入:
1+6/3-5*2
2^3+6/2
输出:
-7
11
注:单单只给程序者,不于加分!
详细解释所采用的数据结构,以及数据算法。程序要加注释!
回答好的还会加分的
就是想不清楚这个的数据结构和算法!才问的!大家积极回答啊

#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