gatieme / CodingInterviews
剑指Offer——名企面试官精讲典型编程题
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing gatieme/CodingInterviews in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler view#include #include #include #include using namespace std; //判断是否为操作符 bool isOperator(char op) { return (op == '+' || op == '-' || op == '*' || op == '/'); } //判断是否为数字 bool isDigit(char op) { return (op >= '0' && op s1;//创建辅助栈 int left = 0, right = 0;//定义左/右操作数 int result = 0;//定义中间结果 string temp; for (unsigned int i = 0; i 0) //防止运算符后面跟分隔符,所以判断一下temp里面是否有数字 { s1.push(atoi(temp.c_str())); temp.clear(); } } else if (isOperator(tokens[i]) && !s1.empty()) { //防止数字后面直接跟运算符,所以这里也要判断一下temp是否还有数字没有提取出来 if (temp.size() > 0) { s1.push(atoi(temp.c_str())); temp.clear(); } right = s1.top(); s1.pop(); left = s1.top(); s1.pop(); result = cal(left, right, tokens[i]); s1.push(result); } } if (!s1.empty()) { result = s1.top(); s1.pop(); } return result; } //中缀表达式转逆波兰表达式 vector infixToPRN(const string & token) { vector v1; int len = token.size();//string的长度 if (len == 0) return v1; stack s1;//存放逆波兰式的结果 int outLen = 0; for (int i = 0; i pirority(s1.top())) { s1.push(token[i]);// 当前操作符优先级比栈顶高, 将栈顶操作符写入后缀表达式 break; }else { v1.push_back(s1.top()); s1.pop(); } } } while (!s1.empty())//输入结束,将栈中剩余操作符出栈输出 { v1.push_back(s1.top()); s1.pop(); } return v1; } int main() { //vector sRPN = {"4", "13", "5" , "/", "+"};//逆波兰表达式 //cout fix = {"4", "+", "13", "/", "5"};//中缀表达式 string fix = "2+2*(1*2-4/2)*1"; vector RPN = infixToPRN(fix); string s_fix; for (auto it = RPN.begin(); it != RPN.end(); it++) { cout << *it << " "; s_fix += *it; s_fix += " "; } cout << endl; cout << "逆波兰表达式结果为:" << evalRPN(s_fix) << endl; system("pause"); return 0; }