代做c++ | assignment作业 | IT – 159.201 Algorithms & Data Structures

159.201 Algorithms & Data Structures

代做c++ | assignment作业 | IT – 这是一个关于IT的题目, 主要考察了关于IT的内容,是一个比较经典的题目, 涉及了c++/IT等代写方面, 这是值得参考的assignment代写的题目

ass代做 assignment代写 代写assignment

S1

Assignment

Write a  c++ program to evaluate a single Reverse Polish Notation expression using a stack.

Notes: the stack must be implemented using a linkedlist (not a static array). handle both the situations of too many numbers (e.g. 12 5 23 *) and too many operators (e.g. 68 49 * +). the operators must be one of: +, *, , / (integer division). Ensure that the operands are popped off the stack in the correct order. Any other operator is not valid, and an error message should be printed in this case. The expression must be read from a *.txt file. A sample code and sample *.txt files are provided to you in Stream. You are allowed to modify and adapt the sample code in any way you want, and modify the text files. However, the assignment code input has to accept the text file in the same format as the example txt files provided (one number or operator per line). You must use command line arguments in the main function to get the file names. The output has to show what the program is reading and the final result of S (use printf or cout). E.g.,

reading number 24 
reading number 15 
reading number 3 
reading operator * 
reading operator + 
The result is 
The algorithm, in pseudocode, is as follows:
Stack S; // a stack of integers
string expr;  
int op1, op2, result;
read the expression into the string expr;
while (there is still something in the expression) {
   if (a space) do nothing;
   if (a number)  push  the number onto S;
   if (an operator) {
     op2 =  top  of S;  
pop  S;// carefull about the order!
     op1 =  top  of S;  
pop  S;
result = apply the operator to op1 and op2;
push  result onto S;
   }
}
display top of S;  // top of S will be the final result

Use our virtual machine to test your submissions (host name vm000296 ). The input/output requirements are essential, please follow them carefully to avoid losing marks. Spaces matter and text is case sensitive. After you are satisfied with the performance of your code as tested in the virtual machine, subm IT a one source file code on Stream by Friday 27 of March 2019. Your name and ID number must appear on top of the file as comments. If you are working in a group, then all names and IDs must appear on top of the file as comments, but you still need to submit individually in both the virtual machine and Stream.