a. Queue qq; b. Queue qq; ok = qq.insert('a'); ok = qq.insert(4); ok = qq.insert('b'); ok = qq.insert(8); ok = qq.del(ch1); ok = qq.insert(2); ok = qq.insert('b'); ok = qq.del(a); ok = qq.insert('f'); ok = qq.del(b); ok = qq.insert('z'); ok = qq.insert(a+b); ok = qq.del(ch2); ok = qq.insert(a*b); ok = qq.insert(ch2); ok = qq.del(a); ok = qq.del(ch2); ok = qq.insert(a+b);
a. Queue qq; b. Queue qq; ok = qq.insert(5); x = 2; ok = qq.insert(6); ok = qq.insert(4); ok = qq.insert(7); ok = qq.insert(x); ok = qq.insert(8); ok = qq.del(y); ok = qq.del(x); ok = qq.insert(y+3); ok = qq.del(y); ok = qq.insert(0); ok = qq.insert(x); ok = qq.del(z); ok = qq.insert(y+1); x = y + z; ok = qq.del(x); ok = qq.insert(x); ok = qq.insert(y); ok = qq.insert(x-1); while (!qq.isEmpty()) ok = qq.insert(x); { while (!qq.isEmpty()) ok = qq.del(x); { cout << x << endl; ok = qq.del(x); } cout << x << endl; } c. Queue qq; d. Queue qq; x = 5; ok = qq.insert(5); y = 7; ok = qq.insert(6); ok = qq.insert(x); ok = qq.insert(10); ok = qq.insert(5); ok = qq.del(a); ok = qq.insert(y); ok = qq.del(b); ok = qq.del(y); ok = qq.insert(a+2); ok = qq.insert(2); ok = qq.insert(a-b); ok = qq.insert(x); ok = qq.insert(b+a); ok = qq.insert(y); ok = qq.insert(a*b); z = x - y; while (!qq.isEmpty()) if (z == 0) { while (!qq.isEmpty()) ok = qq.del(c); { cout << a << b << c << endl; ok = qq.del(x); } cout << x << endl; } else cout << "the end\n";
[0] [1] [2] [3] [4] a. A B C D E Front = 1 Back = 4 Count = 4 ok = qq.insert('F'); [0] [1] [2] [3] [4] b. A B C D E Front = 2 Back = 0 Count = 4 ok = qq.del(value); [0] [1] [2] [3] [4] c. A B C D E Front = 4 Back = 3 Count = 5 ok = qq.insert('G'); [0] [1] [2] [3] [4] d. A B C D E Front = 2 Back = 1 Count = 0 ok = qq.del(value); [0] [1] [2] [3] [4] e. A B C D E Front = 3 Back = 0 Count = 3 ok = qq.insert('H'); [0] [1] [2] [3] [4] f. A B C D E Front = 1 Back = 3 Count = 3 ok = qq.del(value);
Stack st; while (!qq.isEmpty()) { ok = qq.del(value); ok = st.push(value); } while (!st.isEmpty()) { ok = st.pop(value); ok = qq.insert(value); }
Email Me | Office Hours | My Home Page | Department Home | MCC Home Page