| husseinmousa (13) | |||
im trying this code
for this questiom enter the equation then :- 1- change the equation from infix to postfix then print the result 2- Solve the equation and then print the result Allows the use of: stack queue strtok array Figures that fall may be from one status or more Possible equation contains arcs I Analyzed the question, but I analyzed the question for number from status one and does not contain arcs .. Please help me | |||
|
|
|||
| L B (3327) | |
|
Please do not spam, you already have a thread: http://www.cplusplus.com/forum/general/56656/ | |
|
|
|
| unoriginal (55) | |
|
A notes: 1. Abstain from using gets -- it has several flaws in design. Use getline instead. Also, if you are using C++ then it would be better to use C++ streams instead of a mix of both C and C++. 2. Line 219-225. The loop condition is not proper. You require the stack to be empty to enter the loop and yet you pop items from the stack inside the loop, even though it is empty? 3. I would suggest you to include more comments in your file in the future. 4. You really shouldn't be using strtok(). The assignment requires you to use it? I'm surprised. 5. In standard C++ the header file should be <iostream> not <iostream.h>. 6. Rather than using fixed length C Strings, use the std::string class from <string>. It, at least, is easier to use. 7. Use switch cases wherever you can, instead of using a long if... else if... branch. 8. Organise the implementations of Stack in different headers and source files. E.g., Stack.h, Stack.c. Finally, a post script: In deciphering expressions I would suggest you first learn a bit about BNF. It will be of immense help to you if you wish to tokenize and handle such expressions in an easier way. | |
|
|
|
| L B (3327) | |
|
Let's try and divert comments to one thread: http://www.cplusplus.com/forum/general/56656/ ;) | |
|
|
|
| husseinmousa (13) | |
|
this thread http://www.cplusplus.com/forum/general/56656/ doesnt open i dont know why plz delete it and divert comments to this thread http://www.cplusplus.com/forum/general/56715/ | |
|
|
|
| husseinmousa (13) | |
|
now what i do ??? can anyone help me and edit my programme ?? | |
|
|
|
| L B (3327) | ||
All right, I'll answer in this thread then.
If you are allowed to use these, why are you trying to make them yourself? For stacks, just #include <stack> and you can use std::stack<> as described here: http://www.cplusplus.com/reference/stl/stack/For queues, just #include <queue> and you can use std::queue<> as described here: http://www.cplusplus.com/reference/stl/queue/
| ||
|
Last edited on
|
||
| husseinmousa (13) | |
| i know > I analyzed the question and the code above in the subject, but I need anyone that I want him to become adjusted to the number from status of one or more .. and solve the problem arcs | |
|
|
|
| L B (3327) | |
| Is the code you show provided or your own? | |
|
|
|
| husseinmousa (13) | |
| I have done this code, but it reads a number from one status and does not solve the problem of arcs .. Knowing that in the question can contain arcs | |
|
|
|
| husseinmousa (13) | |
|
Enter the Basic mathematical equation such as 2 +3 * 4% 3 Possible contain calculations +-/^%* Converted from infix to postfix And print after conversion the numbers we entering may be from one status or more ( 23+445*4%8 ) The equation can contain arcs And calculates the output and marked by | |
|
|
|
| L B (3327) | |
|
By 'arcs' do you mean 'parenthesis'? Also, I recommend deleting that code you wrote for the stack class. Just use std::stack instead, as you are allowed to do so. http://www.cplusplus.com/reference/stl/stack/ As for actually doing the program, I'd recommend looking at one character at a time and using recursion for the (). | |
|
|
|
| unoriginal (55) | |
|
Edit: irrelevant if the arc actually means parenthesis. It doesn't seem like I can delete this post. Are you having trouble with parsing the user input or with calculating? Parsing user input text can be tricky, that is why I had suggested the use of BNF in my earlier post. | |
|
Last edited on
|
|
| husseinmousa (13) | |
|
The equation can contain arcs as (23*2)+(445*4-5)%8 | |
|
|
|
| husseinmousa (13) | |
| I have a problem in that the solution >> can enter without equivalent arcs and I want to enter the equation with arcs .. And that the figures in the equation introduced from one status, such as 2. 3. 5, and I want it from one or more status such as 2. 45. 66. 676 | |
|
|
|
| L B (3327) | |
|
If there are mismatched parenthesis, just assume they all close at the end: (4+(3-1)*5 you could assume it has a ) at the end. As for different number of digits, why would that be any sort of problem? | |
|
|
|
| husseinmousa (13) | |
|
i dont understand any thing i need anyone edit my programme please >>> pleaseeeeeeeeeee | |
|
|
|