C++计算器程序设计

来源:百度知道 编辑:UC知道 时间:2024/06/06 07:10:38
设计一个能实现计算器功能的C++程序,可以进行加、减、乘、除(另外当加上阶乘、正弦、余弦和指数的其中或全部)运算。
要用VS2005编写的~用C++编 我是C++的入门者~难了会没学的

#include <iostream> // For stream input/output
#include <cstdlib> // For the exit() function
#include <cctype> // For the isdigit() function
using std::cin;
using std::cout;
using std::endl;

void eatspaces(char* str); // Function to eliminate blanks
double expr(char* str); // Function evaluating an expression
double term(char* str, int& index); // Function analyzing a term
double number(char* str, int& index); // Function to recognize a number

const int MAX = 80; // Maximum expression length,
// including '\0'
int main()
{
char buffer[MAX] = {0}; // Input area for expression to be evaluated

cout << endl
<< "Welcome to your friendly calculator."
<< endl