公共字符串【】s=...{“a“、“b“、“c“};
公共無效運行()...{
int j2//指向要切換的位置。
int sLength = s.length
for(int I = 0;我& ltgetP(標準長度);I++)...{ //外部循環以獲取所有組合。
string【】tempString = s . clone();//因為對象傳遞的是句柄,也就是地址,為了保持原數組不變,必須使用對象克隆。
for(int j = 0;j & lt我;J++)...{ //i次交換
J2 = j %(s length-1);
change(J2,tempString);
}
for(int l = 0;l & lt長度;L++)...{ //輸出本次交換後的安排。
system . out . print(tempString【l】);
}
system . out . println();
}
}
公共int getP(int I)...{ //獲取所有的總排列數。
int all = 1;
for(int j = I;j & gt0;j -)...{
all = all * j;
}
全部退回;
}
公共void更改(int i,String【】tempString)...{//
string t =““;
t = tempString【I】;
tempString【I】= tempString【I+1】;
tempString【I+1】= t;
}
公共靜態void main(String[] args)...{
full array fa = new full array();
fa . run();
}
}