• Nie Znaleziono Wyników

push – adding a real number to the queue (with memory allocation if necessary

N/A
N/A
Protected

Academic year: 2021

Share "push – adding a real number to the queue (with memory allocation if necessary"

Copied!
1
0
0

Pełen tekst

(1)

1. Write a program which implements an unbounded queue (a First-In-First-Out structure using sequential memory storage), aimed at storing real numbers, and a set of methods operating on this structure:

• the default constructor (with some starting memory allocation),

• the destructor (with memory deallocation),

• the copy-constructor (with memory allocation),

• the assignment operator= (with memory dellocation and allocation),

• the comparison operator==,

• push – adding a real number to the queue (with memory allocation if necessary),

• pop – removig from the queue a real number placed there as first or throwing an empty queue exception,

• front – returning the first number or throwing an empty queue exception,

• back – returning the last number or throwing an empty queue exception,

• print – printing the values which are in the queue currently in the order of placement,

• empty – informing whether the queue is empty,

• size – returning the number of items in the queue,

• clear – removing all the items from the queue.

The program should use all these methods to make the operations as follows:

1) create a queue containing the numbers given by the user, 2) print the contents of the queue,

3) remove two values from the queue and print them, 4) print the first and the last number,

5) print the number of values in the queue if it is nonempty, or an appropriate message otherwise,

6) clear the queue.

Cytaty

Powiązane dokumenty

Write a program which implements a bounded stack (a Last-In-First-Out structure using sequential memory storage), aimed at storing real numbers, and a set of methods operating on

Write a program which implements an unbounded vector container (using sequential memory storage) as a template structure (aimed at storing values of any type), and

Implement an unbounded queue (using non-sequential memory storage – the linked list) as a template structure (aimed at storing values of any type), and a set of methods operating

Write a program which implements an unbounded sorted list (using the single or double- linked list) as a template structure (aimed at storing values of any type and ordering them

We deal with the problem of finding from the decimal expansion of x, the first k (where k is a given integer) partial quotients of the regular continued fraction expansion of x..

Soon after that, employing Vinogradov’s idea, Hua Loo Keng [3] proved that if B is a sufficiently large positive constant and N is sufficiently large, then the even numbers in (2, N

That is why a contrastive analysis indicated differences in ways of categorizing semantic categories of colors existing in particular languages what stems from the

In the present paper we are concerned with the following problem: What conditions have to be imposed on an analytic func- tion f : M → R in order for it to be analytically equivalent