import java.util.Scanner;
import static java.lang.System.*;
public class 新二进制转换 {
public static void main(String[] args ) {
int c = 0;
while (c == 0)
{
out.println("请输入数字");
Scanner num = new Scanner (in);
out.println("请再输入一遍");
Scanner b = new Scanner (in);
if(num!=b){
out.println("两次输入不一致");
}
if(num!=b){
continue;
}
else{
String a ="";
while(num!=(new)0&&b!=(new)0){
a = num%2+a;
num = num/2 ;
}
System.out.println(b+"的二进制为"+a);
}
}
}
}
//在22行提示我缺少标识符是怎么回事??
//在22行还提示java: 需要')'
package com;
import java.util.Scanner;
import static java.lang.System.*;
public class Mian2 {
public static void main(String[] args) {
int c = 0;
while (c == 0) {
out.println("请输入数字");
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
out.println("请再输入一遍");
int b = scanner.nextInt();
if (num != b) {
out.println("两次输入不一致");
}
if (num != b) {
continue;
} else {
String a = "";
while (num != 0 && b != 0) {
a = num % 2 + a;
num = num / 2;
}
System.out.println(b + "的二进制为" + a);
}
scanner.close();
}
}
}