The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d .
Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet.
Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1.
Definition
標簽:
government
streamline
important
alphabet
上傳時間:
2015-06-09
上傳用戶:weixiao99
編寫一個java應用程序。用戶從鍵盤輸入一個1-9999之間的數,程序將判斷這個數是幾位數,并判斷這個數是否回文數。回文數是指將數含有的數字逆序排列后得到的數和原數相同,例如12121,4224,6778776等都是回文數。
1)程序具有判斷用戶的輸入是否為合法整數的功能。對非法輸入(例如含有字母)要進行處理。
2)要判斷輸入數的位數,并輸出相關信息。
3)要判斷是否回文數。
二、二戰期間,英國情報人員獲取德軍的一機密電報,電報的內容為:
bzdz izu sxgzd vs lh ,vpzg woflsh vs vwrh vhlsddlmp glm wrw gzy vsg .gflyz gstfzu bvsg gzsd hdmlp vml lm ,hghzvy wmz hwiry mvvdgvy izd z hzd vivsg ,ltz tmlo tmlO
情報人員已經知道,這段電報的加密方式為:
1. 首先將字符串的順序顛倒。
2. 字母互換的規律為:A->Z, B-Y, C-X...X->C, Y->B, Z-A a->z, b->y, c-x...x->c, y->b, z->a.
3. 非字母字符保持不變。
請編程幫助情報人員破譯這份機密電報。給出注釋良好的源程序和程序運行后的結果。
標簽:
java
9999
編寫
應用程序
上傳時間:
2017-06-02
上傳用戶:dengzb84