Sau đó nó xóa hai mục đầu tiên và hiển thị danh sách một lần nữa. Đây là kết quả: Danh sách (đầu tiên - cuối cùng): 66 44 22 11 33 55 Danh sách (đầu tiên - cuối cùng): 22 11 33 55 Chú ý thêm vào lặp đi lặp lại ở mặt trước của danh sách đảo ngược thứ tự của các mục, trong khi chèn lặp đi lặp lại ở cuối bảo vệ trật tự. | int j int position size - newSize char temp arrChar position save first letter for j position 1 j size j shift others left arrChar j-1 arrChar j arrChar j-1 temp put first on right ------------------------------------------------------------ - public static void displayWord if count 99 if count 9 count for int j 0 j size j arrChar j if count 6 0 ------------------------------------------------------------ - public static String getString throws IOException InputStreamReader isr new InputStreamReader BufferedReader br new BufferedReader isr String s return s ------------------------------------------------------------ end class AnagramApp The rotate method rotates the word one position left as described earlier. The displayWord method displays the entire word and adds a count to make it easy to see how many words have been displayed. Here s some sample interaction with the program Enter a word cats 1 cats 2 cast 3 ctsa 4 ctas 5 csat 6 csta 7 atsc 8 atcs 9 asct 10 astc 11 acts 12 acst 13 tsca 14 tsac 15 tcas 16 tcsa 17 tasc 18 tacs 19 scat 20 scta 21 satc 22 sact 23 stca 24 stac Is it only coincidence that scat is an anagram of cats You can use the program to anagram 5-letter or even 6-letter words. However because the factorial of 6 is 720 this may generate more words than you want to know about. - 213 - Anagrams Here s a different kind of situation in which recursion provides a neat solution to a problem. Suppose you want to list all the anagrams of a specified word that is all possible letter combinations whether they make a real English word or not that can be made from the letters of the original word. We ll call this anagramming a word. Anagramming cat for example would produce cat cta atc act tca tac Try anagramming some words yourself. You ll find that the number of possibilities is the factorial of the number of .