MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / rpn

Function rpn

Spoj_problems/ONP/solution.cpp:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10*/
11
12void rpn(string str, int n){
13 stack<char>s;
14 for(int i=0;i<n;i++){
15 if(str[i] == '('){ //Ignore opening brackets
16 continue;
17 }
18 else if(str[i]>='a' && str[i]<='z'){
19 cout<<str[i]; //Print Operands
20 }
21 else if(str[i] == '+' || str[i] == '*' || str[i] == '-' || str[i] == '/' || str[i] == '^'){
22
23
24 s.push(str[i]); //Store operators in stack
25 }
26 else if(str[i] == ')'){
27 cout<<s.top(); //Print the top most operator from stack whenever closing brackets occur
28 s.pop(); //remove operators from stack.
29 }
30 }
31}
32int main()
33{
34 jaadu;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected