Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.Arrays;
- public class Main {
- public static void main(String[] args) throws Exception{
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String[] normal = br.readLine().split("");
- String[] reverse = new String [normal.length];
- int swap = 0;
- for(int i=0;i<normal.length;i++){
- reverse[i] = normal[normal.length-i-1];
- }
- out: for(int i=0;i<normal.length;i++){
- if(normal[i].equals(reverse[i])){
- continue out;
- }
- else{
- for(int x=i+1;x<normal.length;x++){
- if(normal[x].equals(reverse[i])){
- for(int b = i+1;b<=x;b++) {
- normal[b] = normal[b - 1];
- swap++;
- }
- normal[i] = reverse[i];
- continue out;
- }
- }
- }
- }
- System.out.println (swap);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement