Professional Documents
Culture Documents
Exercise
5
2. Write
a
program
which
reads
two
positive
integers
and
,
,
and
finds
the
th
largest
element
from
amongst
real
numbers,
using
an
array
of
size
10.
[kthlargest.cpp]
3. Write
a
program
which
reads
an
integer
list
,
and
an
integer
that
is
smaller
than
(),
and
finds
a
subsequence
, + 1, , + 1 of
length
such
that
the
sum
[] + [ + 1] + + [ + 1]
is
maximum
over
all
such
subsequences
of
length
.
The
program
should
print
the
value
of
and
the
sum.
Make
your
computation
as
efficient
as
possible
by
avoiding
repetitive
addition
of
the
same
elements.
[maxSum.cpp]
4. Given
a
list
containing
integers,
write
a
function
to
compute
and
print
all
the
products
of
the
elements
in
the
list
excluding
one
element
at
a
time.
Make
your
function
recursive.
Make
your
computation
as
efficient
as
possible
by
avoiding
repetitive
addition
of
the
same
element.
[allButOne.cpp]