plzzzzzzzzzz help me plzzzzzzzzzzzz

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


The numbers you enter from one status or more than one status


Possible that the equation contains the arcs

plz help me

thanks for all
What is it you want help with?
i need the right programme plz
I doubt anyone will write the program for you. Try yourself and if you have more specific questions you can ask them here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# include <stdio.h>
# include <iostream.h>
# include <math.h>
# define SIZE 100
class Stack
{
    private:
  
 char st[SIZE];
 int Top;
  
 public:
 
  Stack()
 {
  Top=0;
 }
 
 ~Stack()
  {
 
  }
 
 char pop()
 {
  if(!isEmpty())
  {
  
   --Top;
   return st[Top];
   
  
  }
  else
  {
   cout<<"Sorry ,This is Empty Stack \n\n";
   return NULL;
  
  
  }
 
 }
 void push(char v)
 {
  if(isFull())
  {
   cout<<"Sorry,Stack is Overload \n\n";
   
  }
  else
  {
   st[Top]=v;
   Top++;
   
  }
 }
 int isFull()
 {
  return Top>=SIZE;
 }

 int isEmpty()
 {
  return Top<=0;
 }
 
 
};

class EvalStack
{
    private:
  
 int Ev[SIZE];
 int Top;
  
 public:
 
  EvalStack()
 {
  Top=0;
 }
 
 ~EvalStack()
  {
 
  }
 
 int pop()
 {
  if(!isEmpty())
  {
  
   --Top;
   return Ev[Top];
   
  
  }
  else
  {
   cout<<"Sorry ,This is Empty Stack \n\n";
   return NULL;
  
  
  }
 
 }
 void push(int v)
 {
  if(isFull())
  {
   cout<<"Sorry,Stack is Overload \n\n";
   
  }
  else
  {
   Ev[Top]=v;
   Top++;
   
  }
 }
 int isFull()
 {
  return Top>=SIZE;
 }

 int isEmpty()
 {
  return Top<=0;
 }
 
 
};

int isOperator(char T)
{
 if(T=='+'|| T=='/'|| T=='*' || T=='-' || T=='^' || T=='%')
  return 1;
 else
  return 0;
}
int prio(char T)
{
 if(T== '/' || T=='*' || T=='%')
  return 100;
 else if(T=='^') 
  return 1000;
 else if(T=='+' || T=='-')
  return 50;
 
 else if(T==')' || T=='(')
  return 1500;
}
int Evaluat(int x, int y,char z )  
{
  int result;
  if(z=='+')
  {
  result=x+y;
  return result;
  }
 else if(z=='-')
  {
  result=y-x;
  return result;
  }
 else if(z=='*')
  {
  result=x*y;
  return result;
  }
 else if(z=='/')
  {
  result=y/x;
  return result;
  }
 else if(z=='%')
  {
  result=pow(y,x);;
  return result;
  }
 else if(z=='^')
  {
  result=fmod(y,x);
  return result;
  }
 
}
 
 
void main()
{
 EvalStack Eval;
 Stack S;
 int i=0;
 char exp[100];
 char postFix[100];
    
    printf("Please enter Expression to evaluate:\n");
 gets(exp);
 char *p=exp;
 while(*p)
 {
  char T=*p++;
  
  if(!isOperator(T))
  {
 // cout<<T;
  postFix[i]=T;
  i++;
  }
  else if(isOperator(T))
  {
   if(S.isEmpty())
   S.push(T); 
   else
   {
    char v=S.pop();
    while(prio(T)<= prio(v)&&S.isEmpty()S)
    {   
 //       cout<<v;
     postFix[i]=v;
     i++;
     v=S.pop();
    }
         if(prio(T)>prio(v))
    S.push(v);
    S.push(T);
    
   }
  }
 }
  while(!S.isEmpty())
 {
  
  char z=S.pop();
  postFix[i]=z;
  i++;
 // cout<<z;
  cout<<"\n\n";
  
 
  
 }
     postFix[i]=NULL;
  cout<<postFix<<"\n";
  int j=0;
  while(postFix[j]!=NULL)
  {
   if(!isOperator(postFix[j]))
   {
    Eval.push(postFix[j]-'0');
     
   }
   else
  
   {
    char z=postFix[j];
    int x=Eval.pop();
    int y=Eval.pop();
   // int f=x-'0';
   // int s=y-'0';
    int result=Evaluat(x,y,z);
    Eval.push(result);

   }
   j++;
  }
  int q=Eval.pop();
  
  cout<<"The Final result for this Expression:"<<" "<<exp<<" "<<"is equal:"<<q<<"\n";

     if(!Eval.isEmpty())
  cout<<"syntax Erorr"<<"\n";
 
  
 
 
 
 
}


This program, which I worked, but this program to number from one status and does not contain arcs I want the program can contain arcs and numbers from more than one status
plzz anyone help me plzzzzzzzzz
Do you have to write your own stack? Because your assignment says that it allows the use of stack and standard C++ libraries already have a stack class:
http://cplusplus.com/reference/stl/stack/

And also a queue:
http://cplusplus.com/reference/stl/queue/
Last edited on
Topic archived. No new replies allowed.