我想知道你将如何改变二进制数和反向的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