Download 1. Write a program which reads 5 integers and then prints the

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
1. Write a program which reads 5 integers and then prints the multiplication table for these integers. For example,
for the numbers 1,2,3,1,2 we should get the result
1 2 3 1 2
1 1 2 3 1 2
2 2 4 6 2 4
3 3 6 9 3 6
1 1 2 3 1 2
2 2 4 6 2 4
2.
3.
4.
5.
6.
7.
8.
9.
10.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and then prints a message informing whether the array contains a positive number.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and then prints a message informing:
• whether the numbers in the array are ordered (in the ascending or the descending order)
• whether the array is symmetric
• whether a value occurs in the array more than once.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and then prints all the couples (unordered pairs) of elements of this array such that the sum of the
elements of the pair is smaller than a value L given by the user.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and then, depending on the choice of the user:
• computes the number of odd elements (values) and the number of even elements in the array,
• displays the length of a longest fragment of the array containing positive values only,
• reads the values L and R (the numbers should be positive and not greater than the length of the array)
and then reverses the values in the fragment of the array starting at the L-th element and ending at the
R-th element.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, then moves its contents one position „right” (i.e,, the first element should move to the second
position, the second – to the third one etc., the last one should move to the first position, e.g., the array 1,2,3,4
should change to 4,1,2,3), and displays the array once again.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and next modifies the contents of the array by considering disjoint pair consisting of neughbouring
elements, and replacing by 0 the smaller value in the pair if its elements are not divisible one by another
(where the disjoint pairs are chosen i such a way that the first element of the array is the first element of the
first pair, and the last element of an array of the odd length does not belong to any pair). Example: the array
3,-2,2,2,3,0,2,-3,-3,1,4,3,0 is changed to 3,0,2,2,3,0,2,0,-3,1,4,0,0.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, reads an integer L, and next considers disjoint triples consisting of neughbouring elements and
prints the information how many such triples have their arithmetic means greater than L (where the disjoint
triples are chosen i such a way that the first element of the array is the first element of the first triple, and the
last element(s) of an array of the length not divisible by 3 do not belong to any triple). Example: the result for
the array 1,1,1,9,2,3,9 and L=4 should be 1, for the array 9,9,9,9,9,9,9 and G=8 the result should be 2.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and next prints the information how many triples of neighbouring elements of the arrray satisfy the
conditions: the sum of the first and the third element of the triple is smaller than a value G given by the user,
and the product of all the elements of the triple is divisible by 3. Exaple: for G=3 and the array
2,4,5,3,5,6,- 9, 1,3 the result should be 2.
Write a program which creates an array of integers of the length provided by the user, reads its contents,
displays it, and next prints all these ordered pairs created from the elements of the array which consist of
elements on different positions and the distance between the arithmetic mean of the values in the pair ane the
arithmetic mean of all the elements of the array is smaller than G, where G is an integer provided by the user
(example: for the array 1,7,-2,3,0 and G=2 the program should print the pairs (1,3) (3,1), (1,0), (0,1), (7,-2), (2,7), (7,0), (0,7), (3,0), (0,3), (-2,3), (3,-2) in an arbitrary order).