import java.util.Scanner; public class Main{ public static void main(String args[]){ int ri , repeat; int n; Scanner in = new Scanner(System.in); repeat = in.nextInt(); for(ri = 1 ; ri <= repeat ; ri++){ n=in.nextInt(); dectobin(n); } } static void dectobin(int n){ int tmp=n; int []a=new int[100]; a[0]=0; int k=0; while(true){ if(tmp==0){ break; } else { a[k]=tmp%2; k++; tmp/=2; } } if(n!=0){ int stop=a.length-1; while(true){if(a[stop]!=0)break;else stop--;} for(int i=stop;i>=0;i--) System.out.printf("%d", a[i]); } else System.out.println("0"); System.out.println(); } //write your own codes }
时间: 2024-10-12 19:27:26