Job Recruitment Website - Job information - A-z and 0-9 form a 3-digit password. Please list all possible combinations in the console output. (java code implementation)
A-z and 0-9 form a 3-digit password. Please list all possible combinations in the console output. (java code implementation)
Package code segment;
Import java.util. *;
Common class sorting {
Static int count = 0;;
static char[] buf = { ' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ',' 8 ',' 9 ',' 0 ',' a ',' b ' };
Static list & lt string & gtlist = new ArrayList & lt string & gt ();
public static void main(String[]args){ select(buf,list,3);
for (String str : list) {
system . out . println(str);
}
System.out.println ("total:"+count); }
Public static void select(char[] source, List & lt string & gt array list,
int num) {
int l = source.length
Char[] temp = new char [num];
System.arraycopy(source,0,temp,0,num);
ArrayList.add (new string (temp)););
for(int I = num; I & ltl;; i++) {
for(int j = 0; j & ltnumj++) {
char temp char = temp[j];
temp[j]= source[I];
ArrayList.add (new string (temp)););
temp[j]= temp char;
}
}
}
public static void perm(char[] buf,int start,int end) {
If (start == end) {// When only one letter in the array needs to be fully arranged, it is output as an array.
for(int I = 0; I<= end; i++) {
system . out . print(buf[I]);
}
sort . count++;
system . out . println();
} else {// Multiple letters are all arranged.
for(int I = start; I<= end; i++) {
char temp = buf[start]; //Swap the first element of the array with subsequent elements.
buf[start]= buf[I];
buf[I]= temp;
perm(buf,start + 1,end); //Recursive complete arrangement of subsequent elements
temp = buf[start]; //Restores the swapped array.
buf[start]= buf[I];
buf[I]= temp;
}
}
}
}
- Related articles
- How about CRRC Qingdao Sifang locomotive?
- Why do convenience stores recruit people every day?
- Is there a dormitory in Nanjing Siemens factory?
- What is the level of Henan International Cooperation Group?
- Where is the vocational technical school of Cangzhou West Point technical training?
- Do large dry cleaning factories need EIA?
- Which area does Shaoxing Yao Lu Binhai New City Ecological Park belong to?
- Is Xianning Chibi fun? What are the scenic spots in Chibi?
- How about the wages and benefits of welders in Xuzhou Caterpillar Pavement Machinery Co., Ltd.
- Brief Introduction of Fanfu Courtyard Community