N
N
Nikolay2015-03-21 23:09:37
Programming
Nikolay, 2015-03-21 23:09:37

Calculator implementation?

Hello ! Tell the newbie how the implementation of the calculator in C # in particular, and in general the general algorithm for allocating dynamic memory, priority for operators. The point is that I made an ordinary calculator, according to the book of G. Schildt, but I have no idea how to further develop it into a normal calculator that can take more than a few values).
And as many - as needed and will give priority to multiplication or brackets.
It is best to give a couple of links where they make a professional calculator.
(If in my cal. write 2+2+2 he goes to bed :)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
nmkravsk, 2016-11-11
@zzzmaikzzz

Full of implementations of varying complexity: more difficult , easier , simple , using reverse Polish notation .

V
Viktor Login, 2015-03-21
@BATAZOR

Reverse Polish notation

C
Cyril, 2015-03-22
@Sk1talec

In general, your question is not related to C #, but to programming in general.
If you want to write a full-fledged calculator, with support for functions, then it is better to consider a more general case - Parsing .
Moreover, the skill of building and working with syntax trees can be useful in the future.
The general algorithm is as follows:
1) You build a syntax tree based on the input string.
2) Calculate it recursively.
Something similar is implemented at the link in bobrovskyserg 's comment .

B
bobrovskyserg, 2015-03-21
@bobrovskyserg

Tree calculator, C#. I'll be happy to hear why I'm wrong (about the quality of the code)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question