a. x = 3; b. y = 1; y = 5; Stack st; z = 2; ok = st.push(5); Stack st; ok = st.push(7); ok = st.push(x); ok = st.pop(x); ok = st.push(4); x = x + y; ok = st.pop(z); ok = st.pop(x); ok = st.pop(y); ok = st.push(x); ok = st.push(y); ok = st.push(y); ok = st.push(3); ok = st.push(2); ok = st.push(2); ok = st.pop(y); ok = st.pop(x); ok = st.pop(x); ok = st.push(2); while (!st.isEmpty()) ok = st.push(x); { while (!st.isEmpty()) ok = st.pop(y); { cout << y << endl; ok = st.pop(x); } cout << x << endl; cout << "x = " << x << endl; } cout << "y = " << y << endl; c. x = 0; d. a = 0; y = 5; b = 5; z = y / 2; c = 4; ok = st.push(x); ok = st.push(a); ok = st.push(y); ok = st.push(b); ok = st.pop(z); ok = st.pop(c); ok = st.push(x+1); a = a + 1; ok = st.push(y); ok = st.push(a); ok = st.push(3); ok = st.push(c); while (!st.isEmpty()) ok = st.push(b); { b = a + b; ok = st.pop(z); ok = st.push(b); cout << z << endl; ok = st.push(7); } while (!st.isEmpty()) cout << "x = ",x; { cout << "y = ",y; ok = st.pop(a); cout << "z = ",z; cout << a << " "; }
[0] [1] [2] [3] [4] a. B C D F O Top = 1 ch = 'X' ok = st.pop(ch); [0] [1] [2] [3] [4] b. X Y Z A B Top = 4 ch = 'C' ok = st.push('A'); [0] [1] [2] [3] [4] c. D J K P Q Top = 3 ch = 'X' ok = st.push(ch); [0] [1] [2] [3] [4] d. R V M H A Top = -1 ch = 'C' ok = st.pop(ch);
A. A B + C / D * B. A B + C - D + C. A B C + / D * D. A B * C - D /
A. A * B + C - D B. (A + B) / C - D C. (A - B) * (C - (D + E)) D. (((A - B) * C) + D) / E)
Email Me | Office Hours | My Home Page | Department Home | MCC Home Page