Hide

Problem D
Reverse Words

Write a program that takes a filename as input. The program should open that file and print every single word in that file backwards.

Do not change the original file and do not write a new file with the words reversed, simply print the reversed words.

For each line in the file, you should print one line to the output.

Input

Input consists of:

  1. A filename containing the text to be processed.

The file is guaranteed to exist and be accessible by the given name under the directory "/src/".

Output

Output consists of:

  1. The content of the file with every single word reversed, where each line in the input corresponds to one line in the output.

Sample Input 1 Sample Output 1
reverse_test.txt
raeD ,yraid yadot I edam a .dneirf 
eH saw yrev yldneirf 
Sample Input 2 Sample Output 2
plagueis.txt
diD uoy reve raeh eht ydegart fo htraD sieugalP ehT ?esiW 
I thguoht .ton s'tI ton a yrots eht ideJ dluow llet .uoy 
s'tI a htiS .dnegel htraD sieugalP saw a kraD droL fo eht ,htiS 
os lufrewop dna os esiw eh dluoc esu eht ecroF ot ecneulfni eht snairolhcidim ot etaerc ...efil 

Please log in to submit a solution to this problem

Log in