Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7178fbf

Browse files
made the helper function
1 parent 87437f0 commit 7178fbf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎Data Structures/Stacks/InfixToPrefix.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66
2) Obtain the postfix expression of the modified infix expression.
77
3) Now reverse the postfix expression obtained, which will give us the Prefix expression.
88
*/
9+
10+
bool isOperator(char c)
11+
{
12+
return (!isdigit(c) && isalpha(c));
13+
}
14+
15+
int getPriority(char c)
16+
{
17+
if(c=='+' || c=='-')
18+
return 1;
19+
else if(c=='*' || c=='/')
20+
return 2;
21+
22+
else if(c=='^')
23+
return 3;
24+
}
25+
26+
27+
string InfixToPostfix(string infix)
28+
{
29+
infix = '(' + infix + ')';
30+
string output;
31+
int len = infix.size();
32+
33+
34+
}
935
using namespace std;
1036

1137
int main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /