作业帮 > 综合 > 作业

穷举排列组合列表509102493要这9位数的穷举列表就是所有排列组合的各种可能(3268800种)有软件也行 应该是3

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/22 19:17:54
穷举排列组合列表
509102493
要这9位数的穷举列表
就是所有排列组合的各种可能(3268800种)
有软件也行
应该是326880种 多了个0
一共就9 个数 哪来3268800种排列?
如果重复的数字看做独立的话 有362880种排列.是不是我没理解你的意思啊?
好马上给你穷举出来
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication7;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author Yichuan
*/
public class Main {
/**
* @param args the command line arguments
*/
static final byte a = 5;
static final byte b = 0;
static final byte c = 9;
static final byte d = 1;
static final byte e = 0;
static final byte f = 2;
static final byte g = 4;
static final byte h = 9;
static final byte i = 3;
static String result;
static int count = 0;
static byte[] list = new byte[9];
public static void main(String[] args) throws IOException {
BufferedWriter out = new BufferedWriter(new FileWriter("myfile"));
for(int j = 0; j < 9; j ++){
list[j] = a;
for(int k = 0; k < 9; k ++){
if (k == j){
continue;
}
else{
list[k] = b;
}
for(int l = 0; l < 9; l++){
if( l ==j || l == k){
continue;
}
else {
list[l] = c;
}
for(int m = 0; m < 9; m++){
if(m ==l || m ==j || m == k){
continue;
}
else {
list[m] = d;
}
for(int n = 0; n < 9; n++){
if(n == m || n ==l || n ==j || n == k){
continue;
}
else {
list[n] = e;
}
for(int o = 0; o < 9; o++){
if(o == n || o == m || o ==l || o ==j || o == k){
continue;
}
else {
list[o] = f;
}
for(int p = 0; p < 9; p++){
if(p == o || p == n || p == m || p ==l || p ==j || p == k){
continue;
}
else {
list[p] = g;
}
for(int q = 0; q < 9; q++){
if(q == p || q == o || q == n || q == m || q ==l || q ==j || q == k){
continue;
}
else {
list[q] = h;
}
for(int r = 0; r < 9; r++){
if(r ==q || r ==p || r == o || r == n || r == m || r ==l || r ==j || r == k){
continue;
}
else {
list[r] = i;

for(int z = 0; z < 9; z++){
result += list[z] + "";
}
if (count == 15){
out.write(result + "\n");
result = "";
count = 0;
}
else{
result += ",";
count ++;
}
}
}
}
}
}
}
}
}
}
}

}
}
我已经算过了, 这个程序一共生成 362880 个数字, 因为太大 只能给你txt文件链接了.