Code Monkey home page Code Monkey logo

ahutsunshine / basic-calculator Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 133 KB

ios objective-c 使用栈实现数学表达式求值,完成计算器的基本四则运算(带括号) Using a stack to implement an arithmetic expression evaluation and basic four arithmetic operations (including parenthesis operation)

Objective-C 100.00%
objective-c algorithm calculator parenthesis arithmetic-expression-evaluator arithmetic-expression stack

basic-calculator's Introduction

使用栈实现算术表达式求值

  • 为了更好地理解Foundation,所以没有用NSExpression,而是自己实现一个栈来完成表达式求值。这就是基本运算所依赖的核心算法。

实现的功能

  • 项目实现了带有括号计算器的四则运算,并有删除和清空功能。

项目核心代码

  • Medel文件夹存放了栈实现数值表达式算法的文件:Stack.h Stack.m Calculate.h Calculate.m 。
  • Stack.h和Stack.m是自定义的栈结构文件,Calculate.h定义了一些四则运算需要的成员变量和操作的方法,而Calculate.m则是具体实现了四则运算操作的方法。整个业务逻辑的代码位于ViewController.m的文件中。

算法参考

  • 对四则运算算法表示困惑的同学,可以参考下严蔚敏老师的数据结构教材。

运行效果

basic_calculator_effect

联系方式

Email: [email protected]

Implement

  • We use a customized stack to implement an arithmetic expression evaluation instead of using NSExpression for better understanding Foundation. This is the core algorithm that basic operations depend on.

Function

  • The project implements basic four arithmetic operations with parenthesis which has function of deleting and clearing.

Code file structure

  • The Medel folder stores the file which implements algorithm of arithmetic expression.
  • Stack.h and Stack.m are customized stack struture file .Calculate.h defines a number of member variables and operations for basic arithmetic operations and Calculate.m implements these methods.

Algorithm reference books

  • If are puzzled about this algorithm, you can refer to Data Structure by Weimin Yan.

Running effect

basic_calculator_effect

Contact

Email: [email protected]

basic-calculator's People

Contributors

ahutsunshine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mjwz5294

basic-calculator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.