ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1226. esreveR redrO

why WA 14? please help me !!!!!
Posted by TUITUF_Bahrom 17 Apr 2013 11:06
import java.util.Scanner;
public class T_1226_esreveR_redrO {
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()){
        String set="ABCDEFGHIJKLMNOPQRSTUVXYZWabcdefghijklmnopqrstuvxyzw";
        String s =sc.nextLine();
        String p="";
        for (int i = 0; i < s.length(); i++) {
            if(set.indexOf(s.charAt(i)+"")>-1)
                p=s.charAt(i)+p;
            else{
                System.out.print(p);
                p="";
                System.out.print(s.charAt(i));
            }
        }
        System.out.println(p);
    }
}
}
Re: why WA 14? please help me !!!!!
Posted by Unknown 17 Apr 2013 18:14
public class T_1226 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String l = "";
        char c;
        while (br.ready()) {
            char s = (char) br.read();
            if ((65<=s && 90>=s)||(97<=s && 122>=s)) {
                l = s + l;
            } else {
                System.out.print(l + s);
                l = "";
            }
        }
        System.out.print(l);
    }

}

My code Accepted!!!

Edited by author 17.04.2013 18:28