I didn't say it was an ordered field

import java.io.IOException; public class Anagram { int size, count; char[] arr; public static void main(String[] args) throws IOException { String input = args[0]; size = input.length(); count = 0; arr = new char[size]; for (int i = 0; i < size; i++) arr[i] = input.charAt(i); anagram(size); } public static void rotate(int anagramSize) { int i; int position = size - anagramSize; char temp = arr[position]; // 1st letter for (i = position + 1; i < size; i++) // push the rest left arr[i - 1] = arr[i]; arr[i - 1] = temp; // now put the 1st on the end } public static void anagram(int anagramSize) { int limit; if (anagramSize != 1) // if 1, this is useless this is useless so don't do anything { for (int i = 0; i < anagramSize; i++) { anagram(anagramSize - 1); // anagram the last bits if (anagramSize == 2) // the innermost anagram { for (int i = 0; i < size; i++) // display it System.out.print(arr[i]); System.out.println(); } // end if else rotate(anagramSize); // rotate word } // end for } // end if } // end anagram() }
Comment