1. 程式人生 > >演算法生成1-9,a-b的隨機十位數

演算法生成1-9,a-b的隨機十位數

譬如你行隨機生成小於等於10位的數字   1sd3sd34t5    3g3t44h

演算法如下

public class test {
	public static String[] z = {"0","1","2","3","4","a","b","c","d",""};
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		getAInt(10,"");
	}

	public static String getAInt(int index,String result){
		for(int i=0;i<z.length;i++){
			if(index==1){
				System.out.println(result+z[i]);
				continue;
			}
			System.out.println("開始進入遞迴");
			getAInt(index-1,result+z[i]);	System.out.println("結束遞迴");
		}
		return "";
	}
}