fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. String s = in.next();
  11. char[] s1 = s.toCharArray();
  12. char temp;
  13. for (int i=1;i<s.length();i+=2){
  14. temp=s.charAt(i-1);
  15. s1[i-1]=s.charAt(i);
  16. s1[i]=temp;
  17. }
  18. String s2 = String.valueOf(s1);
  19. System.out.println(s2);
  20.  
  21. }
  22. }
Success #stdin #stdout 0.07s 2184192KB
stdin
abcde
stdout
badce