Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

книги2 / Ilyin-Fundamentals-and-methodology-of-programming

.pdf
Скачиваний:
1
Добавлен:
24.02.2024
Размер:
2.1 Mб
Скачать

Option 2

Given a one-dimensional dynamic array consisting of N real elements. Calculate: product of positive array elements; the sum of the array elements located up to the minimum element. Separately arrange in ascending order the elements in even-numbered places and the elements in odd-numbered places. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 3

Given a one-dimensional dynamic array consisting of N integer elements. Calculate: the minimum absolute element of the array; the sum of the modules of the array elements located after the first element, which is equal to zero. Transform the array so that the first half contains elements in even positions, and the second half contains elements in odd positions. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 4

Given a one-dimensional dynamic array consisting of N real elements. Calculate: number of the minimum element of the array; the sum of the array elements located between the first and second negative elements. Transform the array so that all elements whose modulus does not exceed 5 are placed first, and then all the rest. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Option 5

Given a one-dimensional dynamic array consisting of N real elements. Calculate: number of array elements greater than K ; the product of the array elements located after the element with the largest modulo element. Transform the array so that all negative elements are placed first, and then all positive ones (elements equal to 0 are considered positive). Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

170

Option 6

Given a one-dimensional dynamic array consisting of N real elements. Calculate: product of negative array elements; the sum of the positive array elements up to the maximum element. Perform inversion of array elements. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 7

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the number of the maximum modulo element of the array; the sum of the array elements located after the first positive element. Transform the array in such a way that first all elements are located, the whole part of which lies in the interval [a, b], and then all the rest. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 8

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the maximum modulo element of the array; the sum of the array elements located between the first and second positive elements. Transform the array so that elements equal to zero are placed after all others. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 9

Given a one-dimensional dynamic array consisting of N real elements. Calculate: number of array elements less than K ; the sum of the integer parts of the array elements located after the last negative element. Transform the array so that all elements that differ from the maximum by no more than 20% are placed first, and then all the rest. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 10

Given a one-dimensional dynamic array consisting of N integer elements. Calculate: the product of array elements with odd numbers; the sum of the array elements located between the first and last zero elements. Transform the array so that all positive elements

171

are placed first, and then all negative ones (elements equal to 0 are considered positive). Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Option 11

Given a one-dimensional dynamic array consisting of N integer elements. Calculate: the number of positive array elements; the sum of the array elements located after the last element, which is zero. Transform the array so that all the elements whose integer part does not exceed 1 are placed first, and then all the rest. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 12

Given a one-dimensional dynamic array consisting of N integer elements. Calculate: number of the maximum array element; the product of the array elements located between the first and second zero elements. Transform the array so that the first half contains elements in odd positions, and the second half contains elements in even positions. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Option 13

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the sum of negative array elements; the product of array elements located between the maximum modulo and minimum modulo elements. Sort array elements in descending order. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Option 14

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the number of the minimum absolute value of the array element; the sum of the modules of the array elements located after the first negative element. Compress the array by removing from it all elements whose value is in the interval [a, b]. Fill the vacated elements at the end of the array with zeros. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

172

Option 15

Given a one-dimensional dynamic array consisting of N real elements. Calculate: minimum array element; the sum of the array elements located between the first and last positive elements. Transform the array so that all elements equal to zero are placed first, and then all the rest. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 16

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the number of array elements lying in the interval [a, b]; the sum of the array elements located after the maximum element. Sort array elements in descending order of element modules. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 17

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the sum of array elements with even numbers; the sum of the array elements located between the first and last negative elements. Compress the array by removing from it all elements whose modulus does not exceed 5. Fill the elements freed at the end of the array with zeros. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Option 18

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the number of negative array elements; the sum of the modules of the array elements located after the element with the minimum modulus. Replace all negative elements of the array with their squares and order the elements of the array in ascending order. Functional parts of the program are organized into subroutines; implement a dialog menu for selecting a demonstration of the operation of subroutines.

Option 19

Given a one-dimensional dynamic array consisting of N real elements. Calculate: the sum of positive array elements; the product of the array elements located between the maximum and minimum elements. Sort array elements in ascending order. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

173

Option 20

Given a one-dimensional dynamic array consisting of N real elements. Calculate: maximum array element; the sum of the array elements up to the last positive element. Compress the array by removing from it all elements whose modulus is in the interval [a, b]. Fill the vacated elements at the end of the array with zeros. Functional parts of the program are organized into subroutines; implement a dialog menu to demonstrate the operation of subroutines.

Practical work No. 11. Tasks for independent work on the topic “Vector Container”

Option 1

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the maximum positive element.

Calculate the product of array elements.

Bring positive elements to the screen.

Option 2

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum element.

Calculate the sum of even array elements.

Display negative elements in reverse order.

Option 3

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the minimum positive element.

Calculate the sum of even array elements.

Display the array in reverse order.

174

Option 4

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum negative element.

Calculate the product of non-zero array elements that are multiples of 3.

Display negative elements in reverse order.

Option 5

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum negative element.

Calculate the arithmetic mean of even array elements.

Display non-zero elements in reverse order.

Option 6

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the minimum positive element.

Calculate the product of odd array elements.

Display negative elements on screen.

Option 7

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the minimum positive element.

Calculate the sum of positive array elements that are multiples of 3.

Display non-null elements on the screen.

175

Option 8

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum element.

Calculate the product of non-zero array elements.

Display positive elements in reverse order.

Option 9

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum element.

Calculate the arithmetic mean of negative array elements.

Display the array in reverse order.

Option 10

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum element.

Calculate the arithmetic mean of array elements.

Display the array in reverse order.

Option 11

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum element.

Calculate the sum of array elements.

Bring positive elements to the screen.

176

Option 12

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum negative element.

Calculate the product of negative array elements.

Display non-zero elements in reverse order.

Option 13

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum negative element.

Calculate the arithmetic mean of the positive elements of the array.

Bring positive elements to the screen.

Option 14

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the maximum element.

Calculate the arithmetic mean of odd array elements.

Display negative elements on screen.

Option 15

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum element.

Calculate the arithmetic mean of the positive elements of the array.

Display negative elements in reverse order.

177

Option 16

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum positive element.

Calculate the product of non-zero array elements.

Display non-zero elements in reverse order.

Option 17

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Enter the array from the keyboard.

Find the maximum negative element.

Calculate the sum of negative array elements.

Bring positive elements to the screen.

Option 18

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the minimum element.

Calculate the sum of the positive odd elements of an array.

Bring positive elements to the screen.

Option 19

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the maximum positive element.

Calculate the sum of array elements.

Display non-zero elements in reverse order.

178

Option 20

Given a vector (variable size array). Using, whenever possible, operations (methods) of the type (class) Vector, do the following:

Fill the array with random numbers.

Find the maximum element.

Calculate the arithmetic mean of negative array elements.

Display positive elements in reverse order.

Practical work No. 12. Assignments for independent work on the topic “List”

In the job variants below, the TNode type has the following structure: struct TNode // “node” structure

{

intData; // data field

TNode *Next; // pointer to next element TNode *Prev; // pointer to previous element };

If necessary, you can create a Pointer Node data type. typedef TNode* PNode;

Option 1

Describe the TNode type as an element of a chain of connected nodes (provide the necessary functions: adding nodes, printing list elements, etc.). Display the values of the Data fields of the subsequent and previous record specified at address P, as well as the addresses of the subsequent and previous record.

Option 2

Describe the TNode type as an element of a chain of connected nodes (provide the necessary functions: adding nodes, printing list elements, etc.). There are pointers to the first and last elements of a doubly linked list. Duplicate the first and last elements in the list (add new elements before existing elements with the same values) and display a pointer to the first element of the transformed list.

179