4常量表达式计算器.docx

#include iostream #include cstdlib #include cctype //字符串判定 using namespace std; const int MAX = 1024; double operation(char *str); char * extract(char *str, int index) { char *pstr(nullptr);//处理字符串 int num(0);//记录一下多少对括号 int bufindex(index);//记录下标 do { switch (*(str + index)) { case ): if (0 == num) { ++index; pstr = new char[index - bufindex]; if (!pstr) { throw malloc fail; } //拷贝字符串 strncpy_s(pstr, index - bufindex, str + bufindex, index - bufindex - 1); return pstr; } else { num--; } break; case (: num++; bre

文档评论(0)

1亿VIP精品文档

相关文档