Answer the question
In order to leave comments, you need to log in
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
Full of implementations of varying complexity: more difficult , easier , simple , using reverse Polish notation .
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 .
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 questionAsk a Question
731 491 924 answers to any question