0% found this document useful (0 votes)
104 views2 pages

03 Arrays PDF

The document describes 3 tasks: 1. Swap even values in an integer array that are symmetrical around the array's center. 2. Calculate the distance between the maximum value and the array's endpoints in an integer array. 3. Insert 0 to the left and 1 to the right of the main diagonal in a square integer matrix.

Uploaded by

Gen Kozh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views2 pages

03 Arrays PDF

The document describes 3 tasks: 1. Swap even values in an integer array that are symmetrical around the array's center. 2. Calculate the distance between the maximum value and the array's endpoints in an integer array. 3. Insert 0 to the left and 1 to the right of the main diagonal in a square integer matrix.

Uploaded by

Gen Kozh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Task 1.

In a given array of integers nums swap values of the first and the last array
elements, the second and the penultimate etc., if the two exchanged values
are even.
Example,
{10, 5, 3, 4} => {4, 5, 3, 10}
{100, 2, 3, 4, 5} => {100, 4, 3, 2, 5}
{100, 2, 3, 45, 33, 8, 4, 54} => {54, 4, 3, 45, 33, 8, 2, 100}

Task 2.
In a given array of integers nums calculate integer result value, that is
equal to the distance between the first and the last entry of the maximum
value in the array.
Example,
{4, 100, 3, 4} result = 0
{5, 50, 50, 4, 5} result = 1
{5, 350, 350, 4, 350} result = 3
{10, 10, 10, 10, 10} result = 4

Task 3.
In a predetermined two-dimensional integer array (square matrix) matrix
insert 0 into elements to the left side of the main diagonal, and 1 into
elements to the right side of the diagonal.
Example,
{{2, 4, 3, 3}, {{2, 1, 1, 1},
{5, 7, 8, 5}, => {0, 7, 1, 1},
{2, 4, 3, 3}, {0, 0, 3, 1},
{5, 7, 8, 5}} {0, 0, 0, 5}}

You might also like