{class Tests2020031702 public Private the RANGE static String = "0123456789"; public static void main (String [] args) { // 1-8 bit random combinations for (int len =. 1; len <=. 5; len ++) { the DashBoard Dashboard = the dashBoard new new (len); // initial value dashBoard.println (); the while (dashBoard.add ()) { dashBoard.println (); } // maximum dashBoard.println (); } } / ** * dashboard * / static the dashBoard class { char [] chars; char lastChar = RANGE.charAt (RANGE.length () -. 1); public the dashBoard (int length) { // dashboard display digits this.chars = new char [length] ; // initialize for (int I = 0; I <chars.length; I ++) { chars [I] = RANGE.charAt (0); } } / ** * plus. 1 * @return success * / public Boolean the Add () { / / accumulation starts from the last one for (int I = chars.length -. 1; I> = 0; i--) { // add. 1 IF (RANGE.indexOf (String.valueOf (chars [I])) <( RANGE.length () -. 1)) { chars [I] = RANGE.charAt (RANGE.indexOf (String.valueOf (chars [I])) +. 1); // do not spill out of the loop BREAK; } chars [I ] = RANGE.charAt (0); } // determines whether the maximum value for (int I = 0; I <chars.length; I ++) { iF (! chars [I] = lastChar) { return to true; } } return false; } /** * 打印 */ public void println() { for (int i = 0; i< chars.length; i++) { System.out.print(chars[i]); } System.out.println(); } } }
0 1 2 3 4 5 6 7 8 9 00 01 02 03 04
Modify the range
private static String RANGE = "abcdefg";
Reprint
to b c d e f g c most ac hat EU