日期:2014-05-20  浏览次数:20553 次

急求键盘排列方法.
利用java写出键盘内所有键20位以内的排列方法,包括大写字母和特殊字符.

------解决方案--------------------
没看懂~~
------解决方案--------------------
这个程序只有大写和小写字母的排列,看看是不是你要得.

import java.util.*;
public class DiGui{

public static void main(String[] args) throws Exception {

String[] array = new String[52];
char c1 = 'A ';
for(int i = 0; i < 26; i++){
char temp = (char)(c1 + i);
array[i] = " " + temp;
}
char c2 = 'a ';
for(int i = 26; i < 52; i++){
char temp = (char)(c2 + (i - 26));
array[i] = " " + temp;
}

listAll(Arrays.asList(array), " ");
}

public static void listAll(List candidate, String prefix) {
// if (candidate.isEmpty()) {
System.out.println(prefix);
// }

for (int i = 0; i < candidate.size(); i++) {
if(prefix.length() == 20)
break;
List temp = new LinkedList(candidate);
listAll(temp, prefix + temp.remove(i));
}
}
}