我想知道你將如何改變二進制數和反向的1和0?我知道如何改變一個整數轉換成二進制已經的Java:更改二進制數位的0比1和1比0的
Example 1: 5 as a parameter would return 2
Steps: 5 as a binary is 101
The complement is 010
010 as an integer is 2
代碼爲整數更改爲二進制數
import java.io.*;
public class DecimalToBinary{
public static void main(String args[]) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the decimal value:");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String bynumber = Integer.toBinaryString(i);
System.out.println("Binary: " + bynumber);
}
}
如果有人代碼,請幫忙,謝謝!
並解釋什麼是與您當前密碼的問題。 – Mahesh 2012-04-08 22:48:42
注意到是錯我的代碼,到目前爲止,我只需要在扭轉二進制數例幫助:101 = 010 – TriggerLess 2012-04-08 22:55:42