Professional Documents
Culture Documents
Homework Week 1
Homework Week 1
week
1
1. Write
a
program
which
reads
a
sentence
from
keyboard
and
print
the
sentence
in
to
the
file
“rev.txt”
in
reversed
order.
For
example:
“hello”
-‐>
“olleh”.
2. Write
a
program
including
2
classes:
point
and
lines.
Read
four
points
from
file
“points.txt”
and
write
to
the
screen
if
two
lines
are
across
each
other.
3. Write
a
program
which
reads
a
list
of
complex
numbers
from
the
text
file
“complex.txt”
and
write
out
to
the
screen
the
sum
of
the
list.
4. Write a program to find the greatest common divisor of two integer numbers.
5. Write a program to read a list of real number from the text file “numbers.txt”
and output to the file “numbers.txt” the list of numbers which has increasingly
sorted.
6. Given 5 real numbers, write a program to calculate the sum of the greatest and
smallest numbers.