題目描述:
實現**:
測試結果:public class recursivesearch , // 0 0表示空字元
, // 1
, // 2
, // 3
, // 4
, // 5
, // 6
, // 7
, // 8
// 9
}; static int total = ; //分別表示0~9所代表的字元的個數
public static void main(string args) ; //假設**號碼為234,number[i]表示二維陣列中的行值
int n = number.length;
int answer = new int[n]; //answer[i]表示二維陣列c[i]中的列值
// 綜上所述,當 answer[0]=2時 c[number[0]] [answer[0]]= c[2][2]='c'
recursivesearch(number, answer, 0, n);
} private static void recursivesearch(int number, int answer, int index, int n)
system.out.println();
return;
} for (answer[index] = 0; answer[index] < total[number[index]]; answer[index]++)
}}
電話號碼對應英語單詞
號碼盤一般可以用於輸入字母,如2可以輸入a b c,等等。要求設計號碼所對應的所有組合。如5969872可以對應 jtmwtpa jtmwtpb等。這就相當於排列數,如5對應j k l,以j k l各自引出9對應的w x y z這些數字的組合就構成一棵樹。我們可以構建乙個二維陣列charc 10 1...
電話號碼對應的英語單詞
具體問題描述見 程式設計之美 3.2 號碼對應英語單詞,在本文中主要根據 程式設計之美 中的思想分別利用遞迴與非遞迴的思想實現了 號碼對應英語單詞的構造實現,主要考慮了排列樹的思想,利用遍歷樹中的每個葉子節點來實現所有單詞的集合。對應文中的查詢方法正如 程式設計之美 中介紹的方法一樣,主要根據構造的...
3 2 電話號碼對應英語單詞
原始問題如下 手機上面的數字鍵均對應了幾個字元,譬如2對應了a,b,c。問題是當輸入一段數字後,求出所有可能的字元組合 第一種方法 假設 號碼是n個數字,那麼就n個for迴圈。這方法果斷不好 第二個方法 include include using namespace std char c 10 10...