View Code of Problem 114

import java.util.*;
public class Main {
	 public static void main(String[] args) {
		 Scanner in = new Scanner(System.in);
		 while(in.hasNextLine()){
			 String words = in.nextLine();
			 StringBuffer sb = new StringBuffer();
			 String str = "";
			 for(int i =0;i<words.length();i++) {
				 if(Character.isLetter(words.charAt(i))) {
					 str=words.charAt(i)+str;
				 }else {
					 sb.append(str);
					 sb.append(words.charAt(i));
					 str="";
				 }
			 }
			 sb.append(str);
			 System.out.println(sb);
		 }
	 }
}

Double click to view unformatted code.


Back to problem 114