Queue q = new Queue();
q.Enqueue("Hello");
q.Enqueue("world");
q.Enqueue("just testing");
Console.WriteLine("Queue demonstration:");
for (int i = 1; i <= 3; i++)
Console.WriteLine(q.Dequeue().ToString());
Stack s = new Stack();
s.Push("Hello");
s.Push("world");
s.Push("just testing");
Console.WriteLine("Stack demonstration:");
for (int i = 1; i <= 3; i++)
Console.WriteLine(s.Pop().ToString());
The application produces the following output:
Queue demonstration:
Hello
world
just testing
Stack demonstration:
just testing
world
Hello
q.Enqueue("Hello");
q.Enqueue("world");
q.Enqueue("just testing");
Console.WriteLine("Queue demonstration:");
for (int i = 1; i <= 3; i++)
Console.WriteLine(q.Dequeue().ToString());
Stack s = new Stack();
s.Push("Hello");
s.Push("world");
s.Push("just testing");
Console.WriteLine("Stack demonstration:");
for (int i = 1; i <= 3; i++)
Console.WriteLine(s.Pop().ToString());
The application produces the following output:
Queue demonstration:
Hello
world
just testing
Stack demonstration:
just testing
world
Hello
No comments:
Post a Comment