本帖最后由 shw16888 于 2015-4-8 14:37 编辑
- public class ten {
- public static void main(String[] args){
- toBin(60);
- }
- public static void toBin(int num){
- char [] chs={'0','1'};
- char [] arr=new char[32];
- int pos=arr.length;
- while(num!=0);{
- int temp=num&1;
- arr[--pos]=chs[temp];
- num=num>>>1;
-
- }
-
- for(int i=pos;i<arr.length;i++)
- {
- System.out.print(arr[i]);
- }
-
- }
- }
复制代码 |
|