0% found this document useful (0 votes)
4 views

Task Pack 5 - Algorithms

Uploaded by

hastpauli
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Task Pack 5 - Algorithms

Uploaded by

hastpauli
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

ALGORITHMIZATION AND

PROGRAMMING
TASK PACK 5
ACTIVITIES
Write programs to solve all tasks.
If the task states "an array is given", it means the user inputs the array elements via keyboard.
If the task states “form the array” it means that you need to automatically fill the array elements with
specific numbers according to the task.
If the task specifies the array size N, it means you need to input the variable N, create an array of 100
elements, but fill and work only with the part of an array up to N.
If the task says "output", it means printing to the screen; if the task says "replace", it means modifying
the actual array element.

All tasks
1. An array of size N is given. Input the number N and fill the array with integers. Output the
elements to the left and right of the maximum element, if they exist (if there are multiple
maximums, take the leftmost one).
2. An array of size N is given. Input the number N and fill the array with integers. Swap the minimum
and maximum elements (if there are multiple maximums and minimums, take the first maximum
and the last minimum).
3. An array of size N is given. Input the number N and fill the array with integers. Calculate the sum
of all elements between the minimum and maximum (if there are multiple maximums and
minimums, take the leftmost maximum and minimum).
4. An array of size N is given. Input the number N and fill the array with integers. Find the longest
sequence of consecutive zeros. Output the number of zeros in that sequence (a sequence of zeros
is defined as consecutive occurrences of the number 0).
5. An array of size N is given. Input the number N and fill the array with integers from 1 to 9. Find the
number that appears the most in the array. If multiple numbers appear the same number of times,
output the largest number.
6. An array of size N is given. Input the number N and fill the array with integers. Sort the array in
descending order.
7. An array of size N is given. Input the number N and fill the array with integers. Input numbers A
and B (A < B). Sort all elements of the array between indices A and B (exclusive).
8. An array of size N is given. Input the number N and fill the array with integers. Sort the elements
with even indices in ascending order.
9. An array of size N is given. Input the number N and fill the array with integers. Sort the part of the
array starting from the index of the minimum element to the end of the array in ascending order.

You might also like