class Test 
{ public static void main(String[] args) 
{
String[] strAr= {"1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
String b = "";
int le = strAr.length;
System.out.println("Start" + le);
for (int a=0;a < le*4; a ++)
{ if (a < le)
{
b =  "000" + strAr[a];
}else if (a < le*2)
{
b =  "00" + strAr[a-le]+"Z";
}else if (a < le*3)
{
b =  "0" + strAr[a-le*2]+"ZZ";
}else if (a < le*4)
{
b =  strAr[a-le*3]+"ZZZ";
} System.out.println("this is over code :" + b);
}
}
}

解决方案 »

  1.   

    楼上的,不对哦,结果应该要是这样的(左边的是十进制的,右边的是三十四进制的): 0:  0         
    1:  1
    2:  2
    3:  3
    4:  4
    5:  5
    6:  6
    7:  7
    8:  8
    9:  9
    10:  A
    11:  B
    12:  C
    13:  D
    14:  E
    15:  F
    16:  G
    17:  H
    18:  J
    19:  K
    20:  L
    21:  M
    22:  N
    23:  P
    24:  Q
    25:  R
    26:  S
    27:  T
    28:  U
    29:  V
    30:  W
    31:  X
    32:  Y
    33:  Z
    34:  10
    35:  1A
    ....
    1156: ZZ
    麻烦你再想想,非常感谢!!
      

  2.   

    再补充一下吧,其实就是写一个 十六进制的算法,只不过,十六进制改为了三十四进制
     
    String str34[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                    "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M",
                    "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
      

  3.   

    我刚写了,你看看,行不行class Test 
    { public static void main(String[] args) 
    {
    String[] strAr= {"1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String num = "0000";
    String ge="";
    String shi="";
    String bai="";
    String qian="";
    int s=0;
    int genum=0,shinum=0,bai=0,qian=0;
    int length=strAr.length();
    while(true){
    s++;
    genum++;
    if(genum<length){
    num=num.subString(1,3)+geunm.toString;
    }else{
    genum=0;
    shinum++;
    if(shinum<length){
    num=num.subString(1,2)+shinum.toString+"0";
    }else{
    shinum=0;
    bainum++;
    if(shinum<length){
    num=num.subString(1,1)+bainum.toString+"00";
    }else{
    bainum=0;
    qiannum++;
    if(qiannum<length){
    num=qiannum.toString+"000";
    }else{
    break;
    }
    }
    }
    }
    System.out.println(s+":"+gennum);
    }
    }
    }
      

  4.   

    晕了,楼上的仁兄啊,编辑都不过啊,变量 String bai="";String qian="";int genum=0,shinum=0,bai=0,qian=0; 还有 subString (), 应该是 substring();
      

  5.   

    再补充一下吧,其实不用考虑字符串 "0000" 的,只要 传入一个数,比如 34 ,则变成 10 ,比如输入 35 ,则变成 1A ,用另一句话, DecimalFormat df = new DecimalFormat("0000"); df.format(String.valueOf(10)); 就可以变为 "0010" 了
      

  6.   

    class  T
    {
    static String str34[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                    "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M",
                    "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    public static void main(String[] args) 
    {
    System.out.println("Hello World!");
    function(4,34,"");
    }
    public static void function(int p,int d,String arg){
         if(p==0){System.out.println(arg); return;}
     for(int i=0;i<d;i++){
     arg+=str34[i];
         function(p-1,d,arg);
     arg=arg.substring(0,arg.length()-1);}
    }
    }
      

  7.   

    package javaTest;public class Test1 { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO 自动生成方法存根
    String[] strAr= {"1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String num = "0000";
    int s=0;
    int genum=0,shinum=0,bainum=0,qiannum=0;
    int length=strAr.length;
    while(true){
    s++;
    genum++;
    if(genum<length){
    num=num.substring(0,2)+strAr[genum-1];
    }else{
    genum=0;
    shinum++;
    if(shinum<length){
    num=num.substring(0,1)+strAr[shinum-1]+"0";
    }else{
    shinum=0;
    bainum++;
    if(shinum<length){
    num=num.substring(0,0)+strAr[bainum-1]+"00";
    }else{
    bainum=0;
    qiannum++;
    if(qiannum<length){
    num=strAr[qiannum-1]+"000";
    }else{
    break;
    }
    }
    }
    }
    System.out.println(s+":"+num);
    }
    }

    }
      

  8.   

    public class Test1 { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO 自动生成方法存根
    String[] strAr= {"1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String num = "0000";
    int s=0;
    int genum=0,shinum=0,bainum=0,qiannum=0;
    int length=strAr.length;
    while(true){
    System.out.println(s+":"+num);
    s++;
    genum++;
    if(genum<=length){
    num=num.substring(0,3)+strAr[genum-1];
    }else{
    genum=0;
    shinum++;
    if(shinum<=length){
    num=num.substring(0,2)+strAr[shinum-1]+"0";
    }else{
    shinum=0;
    bainum++;
    if(shinum<=length){
    num=num.substring(0,1)+strAr[bainum-1]+"00";
    }else{
    bainum=0;
    qiannum++;
    if(qiannum<=length){
    num=strAr[qiannum-1]+"000";
    }else{
    break;
    }
    }
    }
    }
    }
    }
    }
      

  9.   

    这是好的,我调试了,一直都运行完了
    public class Test1 { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO 自动生成方法存根
    String[] strAr= {"1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String num = "0000";
    long s=0;
    int genum=0,shinum=0,bainum=0,qiannum=0;
    int length=strAr.length;
    while(true){
    System.out.println(s+":"+num);
    s++;
    genum++;
    if(genum<=length){
    num=num.substring(0,3)+strAr[genum-1];
    }else{
    genum=0;
    shinum++;
    if(shinum<=length){
    num=num.substring(0,2)+strAr[shinum-1]+"0";
    }else{
    shinum=0;
    bainum++;
    if(bainum<=length){
    num=num.substring(0,1)+strAr[bainum-1]+"00";
    }else{
    bainum=0;
    qiannum++;
    if(qiannum<=length){
    num=strAr[qiannum-1]+"000";
    }else{
    break;
    }
    }
    }
    }
    }
    }
    }
      

  10.   


    import java.util.Scanner;public class Test34 {
    public static void Cal(long max) {
    String str34[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
    "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M",
    "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; String result = "";
    String tmpStr = "";
    long tmpI;
    int maxWS = 1;
    int tmpWS;
    tmpI = max;
    // 首先判断输入数字的34进制位数
    while (tmpI / 34 > 34) {
    maxWS++;
    tmpI = tmpI / 34;
    }
    // 输出递增
    for (int i = 0; i < max; i++) {
    tmpI = i;
    tmpWS = maxWS;
    result = "";
    while (tmpWS > 0) {
    tmpStr = str34[(int) Math.floor(tmpI
    / Math.pow(34, (double) tmpWS))];
    result = result + tmpStr;
    if (tmpStr != "0") {
    tmpI = tmpI- (new Double(Math.floor(tmpI/ Math.pow(34, (double) tmpWS)))).longValue() * (new Double(Math.pow(34, (double) tmpWS))).longValue();
    }
    tmpWS--;
    }
    result = result + str34[(int) i % 34];
    System.out.println(result);
    } } public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while (true) {
    long num = in.nextLong();
    if (num == 0) {
    System.exit(0);
    }
    Cal(num);
    }
    }
    }任意输入一个十进制数字,调用Cal()方法打印从1递增到该十进制数字的34进制数
      

  11.   

    public class TestSn {    public static final char EXCEPT_CHAR_I = 'I';
        public static final char EXCEPT_CHAR_O = 'O';
        public static final char REVERT_CHAR = '[';    public TestSn() {    }    public String getNextSn(String sn) {        if (sn == null || sn.equals("")) {
                sn = "0000";
            }        char[] snChars = sn.toCharArray();
            snChars[3] = (char)(snChars[3] + 1);
            for (int i = snChars.length - 1; i >= 0; i--) {
                if (snChars[i] == ':') {
                    snChars[i] = 'A';
                    break;
                }
                if (snChars[i] == EXCEPT_CHAR_I) {
                    snChars[i] = 'J';
                    break;
                }
                if (snChars[i] == EXCEPT_CHAR_O) {
                    snChars[i] = 'P';
                    break;
                }            if (i == 0) {
                    if (snChars[i] == REVERT_CHAR) {
                        return "0000";
                    }
                }
                else {
                    if (snChars[i] == REVERT_CHAR) {
                        snChars[i] = '0';
                        snChars[i - 1] = (char)(snChars[i - 1] + 1);
                    }
                }
            }        return new String(snChars);
        }    public static void main(String[] args) {        TestSn test = new TestSn();
            String sn = "0000";
            int times = 0;
            while (!sn.equals("ZZZZ")) {
                times++;
                sn = test.getNextSn(sn);
                System.out.println(times + ":" + sn);
            }
        }}
      

  12.   

    回复 PCSKiller(电脑杀手)  ,你的输入 1157 ,1158 就会出现java.lang.ArrayIndexOutOfBoundsException: 34
    at com.omiss.gs.code.Test34.Cal(Test34.java:31)
    at com.omiss.gs.code.Test34.main(Test34.java:54)
    Exception in thread "main"
      

  13.   

    优化一下:)
    ----------------------------public class TestSn {    public static final char FIRST_SECT_START = '0';
        public static final char FIRST_SECT_END = '9';
        public static final char SECOND_SECT_START = 'A';
        public static final char SECOND_SECT_END = 'Z';
        public static final char EXCEPT_CHAR_I = 'I';
        public static final char EXCEPT_CHAR_O = 'O';
        public static final String CYCLE_SN_FIRST = "0000";    public TestSn() {    }    public String getNextSn(String sn) {        if (sn == null || sn.equals("")) {
                sn = CYCLE_SN_FIRST;
            }        char[] snChars = sn.toCharArray();
            snChars[3] = (char)(snChars[3] + 1);
            for (int i = snChars.length - 1; i >= 0; i--) {
                if (snChars[i] == FIRST_SECT_END + 1) {
                    snChars[i] = SECOND_SECT_START;
                    break;
                }
                if (snChars[i] == EXCEPT_CHAR_I) {
                    snChars[i] = EXCEPT_CHAR_I + 1;
                    break;
                }
                if (snChars[i] == EXCEPT_CHAR_O) {
                    snChars[i] = EXCEPT_CHAR_O + 1;
                    break;
                }            if ((snChars[i] >= FIRST_SECT_START && snChars[i] <= FIRST_SECT_END)
                    || (snChars[i] >= SECOND_SECT_START && snChars[i] <= SECOND_SECT_END)) {
                    break;
                }            if (i == 0) {
                    if (snChars[i] == SECOND_SECT_END + 1) {
                        return CYCLE_SN_FIRST;
                    }
                }
                else {
                    if (snChars[i] == SECOND_SECT_END + 1) {
                        snChars[i] = FIRST_SECT_START;
                        snChars[i - 1] = (char)(snChars[i - 1] + 1);
                    }
                }
            }        return new String(snChars);
        }    public static void main(String[] args) {        TestSn test = new TestSn();
            String sn = "0000";
            int times = 0;
            while (!sn.equals("ZZZZ")) {
                times++;
                sn = test.getNextSn(sn);
                System.out.println(times + ":" + sn);
            }
        }
    }
      

  14.   

    class Test 
    {public static void main(String[] args) 
    {
    String[] strAr= {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String b = "";
    int le = strAr.length;
    int bLength = le*le*le*le;
    System.out.println("Start" + le);
    for (int a=0;a < bLength; a++ )
    {
      System.out.println("this is over code :" strAr[(a%(le*le*le))/(le*le*le)]+ str[(a%(le*le))/(le*le)]+strAr[(a%le)/le]+ strAr[a%le];
    }
    }
    }没测试过 试一下吧
      

  15.   

    不好意思上面那个是错误的哈.
    class Test 
    {public static void main(String[] args) 
    {
    String[] strAr= {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};
    String b = "";
    int le = strAr.length;
    int bLength = le*le*le*le;
    System.out.println("Start" + le);
    for (int a=0;a < le*le*le*le; a++ )
    {
      System.out.println("this is over code :" + strAr[(a%(le*le*le*le))/(le*le*le)]+ strAr[(a%(le*le*le))/(le*le)]+strAr[(a%(le*le))/le]+ strAr[a%le]);
    }
    }
    }