goody9807
import java.util.Scanner;
 
public class Demo001 {
     
    public static void main(String[] args) {
        String str = "";
         
        Scanner scan = new Scanner(System.in);
         
        str = scan.nextLine();
         
        permutation(str.toCharArray(), 0);
    }
 
    public static void permutation(char[] str, int i) {
        if (i >= str.length)
            return;
        if (i == str.length - 1) {
            System.out.println(String.valueOf(str));
        } else {
            for (int j = i; j < str.length; j++) {
                char temp = str[j];
                str[j] = str[i];
                str[i] = temp;
 
                permutation(str, i + 1);
 
                temp = str[j];
                str[j] = str[i];
                str[i] = temp;
            }
        }
    }
 
}

  

运行结果:

 

分类:

技术点:

相关文章:

  • 2021-10-28
  • 2021-04-05
  • 2021-11-17
  • 2022-01-25
  • 2021-09-01
  • 2021-09-10
  • 2021-11-08
  • 2021-07-16
猜你喜欢
  • 2021-04-30
  • 2021-08-30
  • 2021-11-17
  • 2021-09-09
  • 2021-11-17
  • 2021-08-03
  • 2021-06-20
相关资源
相似解决方案