1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.vci.server.framework.delegate;
 
public class TransformDelegate {
    
    /************转化************/
    public static String sl(int k,int d) 
    { 
        String x; 
        if (d < k) 
        {
            if(k==16)
                x = chang(d);
            else x=new Integer(d).toString();
        } 
        else 
        { 
            int c; 
            int s = 0; 
            int n = d; 
            while (n >= k) 
            { 
                s++; 
                n = n / k; 
            } 
            String [] m = new String[s]; 
            int i = 0; 
            do 
            { 
                c = d / k; 
                if(k==16)  m[i++] = chang(d % 16);
                else m[i++] = new Integer(d%k).toString(); 
                d = c; 
            } while (c >= k); 
            x = chang(d); 
            for (int j = m.length - 1; j >= 0; j--) 
            { 
                x += m[j]; 
            } 
        }
        return x; 
    } 
    
    public static String chang(int d) //change函数
    { 
        String x; 
        switch (d) 
        { 
            case 10: 
                x = "A"; 
                break; 
            case 11: 
                x = "B"; 
                break; 
            case 12: 
                x = "C"; 
                break; 
            case 13: 
                x = "D"; 
                break; 
            case 14: 
                x = "E"; 
                break; 
            case 15: 
                x = "F"; 
                break; 
            default: 
                x = new Integer(d).toString(); 
               break; 
        } 
        return x; 
    } 
 
}