Recursive variable number of bits (that is, those that appear possibility)

Bluntly put into a number of emerging realities may have come out

Direct Code

 

 

com.lm.digui package;

 

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

 

/**

* Change the number of digits straightforward it is to put all the possible are displayed

* Then we will start from where it began

*/

public class changZM {

static int size;

static int count;

static char[] ch = new char[100];

 

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

System.out.println ( "Please enter the letter");

// keyboard input

String s = getString();

// Get the byte length

size = s.length();

 

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

// decomposed into byte letters

ch[i] = s.charAt(i);

}

 

// type in data

doChange(size);

}

// n-1 times to move forward, the n-th cycle

private static void doChange(int n) {

if (n == 1) {

return;

}

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

doChange (n - 1);

if (n == 2) {

printDislay ();

}

move(n);

}

 

}

 

 

/**

* \

* Print out function

*/

private static void printDislay() {

if (count < 99) {

System.out.print(" ");

}

if (count < 9) {

System.out.print(" ");

}

System.out.print(++count + ":");

System.out.print(" ");

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

System.out.print(ch[i]);

}

System.out.print(" ");

System.out.flush();

if (count % 6 == 0) {

System.out.println();

}

 

 

}

 

private static void move (int n) {// the back of the forward movement of a letter

int j;

int posistation = size - n;

char temp = ch[posistation];

for (j = posistation + 1; j < size; j++) {

ch [j - 1] = ch [j];

}

ch[j - 1] = temp;

}

 

/**

* keyboard input

*

* @return

*/

private static String getString() throws IOException {

InputStreamReader in = new InputStreamReader(System.in);

BufferedReader bf = new BufferedReader(in);

String string = bf.readLine();

return string;

}

}

 

 

Guess you like

Origin www.cnblogs.com/limingming1993/p/12153996.html