代码
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>();
char [] charArr = new char[32];
for (int i = 0; i < charArr.length; i++) {
charArr[i] ='0';
}
Scanner sc =new Scanner(System.in);
int x = sc.nextInt();
while (x>0) {
x--;
int n =sc.nextInt();
String binaryString = Integer.toBinaryString(n);
char[] binaryCharArray = binaryString.toCharArray();
for (int i = charArr.length - binaryCharArray.length, r = 0; i < charArr.length && r < binaryCharArray.length; i++, r++) {
charArr[i] = binaryCharArray[r];
}
String res = String.valueOf(charArr);
list.add(res);
}
for (String s : list) {
System.out.println(s);
}
}
}