Homework No. 2
[Basic Control Flow, Functions]
Find the number of your Homework No.2 calculating the
Your program must contain at least
two functions: the main
for input and output and the second function for solving the problem.
Write a program that
(0) reads a set of
floating-point data values from the input, and
prints out the average
of the data (see Exercise 4.24).
(1) reads a set of strings
and prints out the shortest of
(2) reads two natural
numbers and prints out their greatest
(3) reads two natural
numbers and prints out their
(4) reads two strings
and prints out true, if
the second string is a
substring of the
first and false,
(5) reads a positive number and prints out all its divisors.
(6) reads a positive number n
and prints out all prime
numbers, less than n.
(7) reads a set of words
and prints them out in reverse order of their letters
(for example "print" as "tnirp").
(8) reads a set of
positive numbers and prints out their binary
numeral system representations.
(9) reads a set of
positive numbers and prints out their octal
(10) reads a set of
strings of ones and zeros and prints out the numbers (in decimal
are these strings.
(11) reads a positive integer N
and prints the sum of this number and the number generated by the
digits of N in backward
(12) reads a natural
number n and prints out
1 + 2.3 + 3.4.5 + 220.127.116.11 +...+ n.(n + 1)...(2n - 1).
(13) reads a natural
number n and prints out
sum of the prime
divisors of n.
(14) reads a word and prints out "YES",
if it a palindrome, i.e. a
word, that reads the same backward or
(15) reads two words and prints out "YES", if the second
word is made by transposing the letters of the first word (anagram).
(16) reads a string
and prints out all repeating (at least twice)
symbols in it.
(17) reads two positive integers a
and b (a < b) and prints out the count
of integer numbers in the interval
which have no the same digits
(example: in the interval
[119,125] there are 4 such numbers - 120,123,124,125).
(18) reads a positive number n
and prints out first n
numbers (from the sequence 1,2,3,4,5,...) which are divisible by
2, 3 and 5.
(19) reads two natural
and b and prints
out the number of digits of ab
(20) reads a positive number n
and prints out a list of all perfect
numbers (are equal to
the sum of all of their factors),
less than n.
Note: The phrase "reads a set of"
means processing a sequence of inputs, see 4.6 from
4. Basic Control Flow.