Advertisement
jhonbrow

Untitled

Feb 25th, 2020
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5. public static void main(String[] args) throws IOException {
  6.  
  7. Scanner leitor = new Scanner(System.in);
  8. int N = leitor.nextInt();
  9. for (int i = 0; i < N; i++) {
  10. String frase = readLine(leitor);
  11. StringBuilder parte1 = new StringBuilder(frase.substring(0, frase.length() / 2));
  12. StringBuilder parte2 = new StringBuilder(frase.substring(frase.length() / 2, frase.length()));
  13. parte1.reverse();
  14. parte2.reverse();
  15. System.out.println(parte1.toString() + parte2.toString());
  16. }
  17. }
  18.  
  19. public static String readLine(Scanner leitor) {
  20. String line = leitor.nextLine();
  21. while (line.isEmpty())
  22. line = leitor.nextLine();
  23. return line;
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement