• Nie Znaleziono Wyników

pop – removig the greatest value from the list or throwing an empty list exception (with memory deallocation

N/A
N/A
Protected

Academic year: 2021

Share "pop – removig the greatest value from the list or throwing an empty list exception (with memory deallocation"

Copied!
1
0
0

Pełen tekst

(1)

1. 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 in descending order - from the greatest to the lowest), and a set of methods operating on this structure:

• the default constructor,

• 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 value to the list in descending order (with memory allocation),

• pop – removig the greatest value from the list or throwing an empty list exception (with memory deallocation),

• top – returning the greatest value or throwing an empty list exception,

• count – returning the number of occurences of a value,

• empty – informing whether the list is empty,

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

• clear – removing all the items from the list (with memory deallocation).

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

1) create an ordered list of integers containing the numbers given by the user, 2) print the greatest number,

3) remove the greatest value from the list, 4) print the greatest number,

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

6) clear the list.

Compare your implementation of the container with the built-in container priority_queue delivered in the <queue> library.

2. Extend the Student structure from the 2nd task of lab 1 with the comparison operator ( operator< ) comparing students by their average grade. Implement a ranking of students for the competition for scholarships. Use the sorted list implemented in task 1. Allow the user to add many student to the list and then print them ordered (using top and pop methods of the list).

Cytaty

Powiązane dokumenty

Class L of selfdecomposable probability distributions (known also as Levy class L probability measures) appears in probability theory as the solution to the central limit problem..

The linear arboricity la(G) of a graph G, introduced by Harary [8], is the minimum number k for which G has a k-linear coloring.. So it is equivalent to the following conjecture,

Radyewa Marina (Ukraine) Rekun Ivan (Ukraine) Sheiko Sergii (Ukraine) Shtuler Iryna (Ukraine) Sokolovskii Oleh (Ukraine) Sribna Nataliia (Ukraine) Stashko Halyna (Ukraine) Ś

(Kiev National Economic University named after Wadym Hetman, Ukraine) Pavlo Popyk. (National University of Life and Environmental Sciences of Ukraine,

wym w swojej dziedzinie, ekspertem w Krajowej Izbie Gospodarki Morskiej, a przede wszystkim praktykiem ma- jącym w dorobku ponad kilkadziesiąt bardzo skomplikowanych wyburzeń.

(d) Write down the number of customers of Alan’s Diner that were also customers of Pete’s Eats.. A survey of 100 families was carried out, asking about the pets

(d) Find the probability that a student chosen at random from the IB class plays either the clarinet or drums or

Nikt nie daje mu typowej formy umowy, jego istnienia zależy od dwóch oświadczeń: pisemnego złożonego przez oskarżonego, który świadczy o jego gotowości do stawienia się do