1. C++, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.220
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <iostream>
#include <string>
#include <cstring>

using namespace std;


bool isLetter(char ch)
{
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
return true;
return false;
}

bool isVowel(char c)
{
switch(c)
{
case 'a':
case 'o':
case 'e':
case 'i':
case 'u':
case 'A':
case 'O':
case 'E':
case 'I':
case 'U':

return true;
break;

default:
return false;
}
}

int main()
{
string s, buffer;
string save;
string output;

while(true)
{
getline(cin,s);

if(feof(stdin))
return 0;

output = "";

for(int i=0; s[i] != '\0'; i++)
if(isLetter(s[i]))
{
int j = i+1;
while(s[j] != '\0' && isLetter(s[j]))
j++;

if(!isVowel(s[i]))
{
buffer = s.substr(i+1,j-i-1);
buffer += s[i];
}
else
buffer = s.substr(i,j-i);

buffer += "ay";
i = j-1;
output += buffer;
}
else
output += s[i];


cout << output << endl;
}
}

2. Java, Till Fischer, Wrong Answer!!!

package _492_;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

private final static List<Character> vowels = new ArrayList<Character>() {
{
add('a');
add('e');
add('i');
add('o');
add('u');
add('A');
add('E');
add('I');
add('O');
add('U');
}
};

public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(true) {
String line = reader.readLine();
if(line == null) {
break;
}
System.out.print(toPigLatin(line) + "\n");
}
System.exit(0);
}

private static String toPigLatin(String line) {
StringBuilder sb = new StringBuilder();

for(int i = 0; i < line.length(); i++) {
if(Character.isLetter(line.charAt(i))) {
int j = i;
while((j+1 < line.length()) && Character.isLetter(line.charAt(j+1))) {
j++;
}
sb.append(toPigLatin(line, i,j));
i = j;
} else {
sb.append(line.charAt(i));
}

}

return sb.toString();
}

private static String toPigLatin(String line, int i, int j) {
String word = line.substring(i,j+1);
if(!vowels.contains(word.charAt(0))) {
char first = word.charAt(0);
word = word.substring(1);
word += first;

}
word += "ay";
return word;
}

}