1. Erste Version: C, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.000
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <stdio.h>
#include <stdlib.h>

char line[100000];

int main()
{
while(1)
{
gets(line);

if(feof(stdin))
return 0;

int pos=0;
int wordStart=0;
int i;

while(1)
{
if( line[pos] != ' ')
{
wordStart = pos;
while(line[pos+1] != 0 && line[pos+1] != ' ')
pos++;

for(i=pos; i >= wordStart; i--)
printf("%c",line[i]);

}
else
printf(" ");

pos++;
if(line[pos] == 0)
break;
}

printf("\n");
}
}

2. 2. Version, Java, Evgeni Pavlidis

/***
?????
***/

import java.util.*;
import java.io.*;

class Main extends Thread {

private Scanner input = new Scanner(System.in);

public static void main(String... args)
{
(new Main()).start();
}

public void run()
{
while(input.useDelimiter("\n").hasNext())
reverseLine(input.next());
}

private void reverseLine(String l)
{
String words[] = l.split("\\s");
int counter = 0;

for(int i = 0; i < l.length(); i++)
if(l.charAt(i) == ' ')
System.out.print(' ');
else
{
System.out.print( reverseWord(words[counter++]) );
while(i+1 < l.length() && l.charAt(i+1) != ' ')
i++;
}

if(counter < words.length)
System.out.print(" " + reverseWord(words[counter]) );


System.out.println();
}

private String reverseWord(String w)
{
String result = "";
for(int i = w.length()-1; i >= 0; i--)
result += w.charAt(i);

return result;
}
}