选择一组等长的英文单词,例如,一组4个字母组成的单词:

1个回答

  • import java.util.*;

    public class TestCount {

    private static String[] word4s = new String[]{"work","back","come","deal","desk","book","java","tool","face"};

    private static String baseCharacters = "abcdefghijklmnopqrstuvwxyz";

    public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    String inWord = "";

    while (true){

    inWord = scanner.next();

    System.out.println(inWord);

    String regX = "^[0-9]*$";

    if(!inWord.matches(regX)){

    if("exit".equals(inWord)){

    return;

    }else {

    System.out.println("请输入数字!");

    }

    } else{

    searchWord(inWord,word4s);

    }

    }

    }

    public static void searchWord(String inWord ,String[] args){

    int wLength = inWord.length();

    String[] resultS = copyStringArray();

    StringBuffer resultTemp = new StringBuffer();

    boolean flag = false;

    for (int i = 0; i < wLength; i++) {

    String subS = inWord.charAt(i)+"";

    int subI = new Integer(subS);

    String char1 = baseCharacters.charAt(subI)+"";

    String char2 = baseCharacters.charAt(subI+10)+"";

    String char3 = "";

    if (subI