割り当ての場合、文字列を7ビットバイナリに変換しようとしています。ただし、Integer.toBinaryString(int)は使用できません。これは私が7ビットのバイナリへのcharの整数ASCII表現に変換する方法については、これまで文字列を7ビットバイナリに変換する方法
public static int[] encodeToBit(String str) {
int[] convertString = new int[str.length() * 7];
for (int i = 0; i < convertString.length; i++) {
convertString[i] = (int)str.charAt(i);
for (int j = convertString.length; j >=0 ; j--) {
while (true) {
convertString[i] =
}
}
}
return convertString;
}
何かアドバイスを持っているものです。
編集: 例えば、encodeToBit(「C」)が出力配列
べきである[1、0、0、0、0、1、1]
と1Sあなたは7ビットのバイナリで正確に何を意味するのですか? –
あなたは私たちにサンプル入力と所望の出力を与えることができますか? –
私はこれがあなたの目的に到達するためにあなたを助けることができると思います。http ://stackoverflow.com/a/6393904/2187972 – seth2810