- public static void trans(int num,int base,int offset)
- {
- if(num==0)
- {//当num=0,输出为0.
- system.out.println(0);
- }
- char[]chs={"0","1","2","3","4","5","6","7","8","9"
- ,"10","A","B","C","D","E","F"};
- char[]arr=new char[32];
- int pos=arr.length;
- while(num!=0)
- {
- int temp=num&base;
- arr[--pos]=cha[temp];
- num=num>>>offset;
- }
- for(ine pos;x<arr.length;x++)
- {
- system.out.prite(arr[x]);
- }
- }
复制代码 |
|