小乐乐喜欢数字,尤其喜欢0和1。他现在得到了一个数,想把每位的数变成0或1。如果某一位是奇数,就把它变成1,如果是偶数,那么就把它变成0。请你回答他最后得到的数是多少。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.next();
StringBuffer sb =new StringBuffer();
for(int i=0;i<a.length();i++){
String tmp;
if ((int)a.charAt(i)%2==0) {
tmp = "0";
} else {
tmp="1";
}
sb.append(tmp);
}
System.out.print(Integer.parseInt(sb.toString()));
}
} import java.util.*;
public class Main {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int count = 0;
while (n != 0) {
int a = n % 10;
if (a % 2 == 0) {
list.add(0);
} else {
list.add(1);
}
n /= 10;
}
for (int i = list.size() - 1; i >= 0; i--) {
count = 10 * count + list.get(i);
}
System.out.println(count);
}
}
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 利用正则表达式来替换
// while (in.hasNextLong()) { // 注意 while 处理多个 case
// String str = in.nextLine().trim();
// String req1 = "[2468]";
// String req2 = "[3579]";
// String temp1 = str.replaceAll(req1, "0");
// String temp2 = temp1.replaceAll(req2, "1");
// System.out.println(Integer.parseInt(temp2));
// }
while(in.hasNextLine()){
String str = in.nextLine().trim();
String temp = "";
for (char c: str.toCharArray()
) {
if (c % 2 == 1){
temp = temp + "1";
}else {
temp = temp + "0";
}
}
while(temp.startsWith("0") && temp.length() > 1){
temp = temp.replaceFirst("0", "");
}
System.out.println(temp);
}
}
} import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer num = scanner.nextInt();
//将数字转化成字符
String str = num.toString();
int countNum = str.length();
int[] toArray = new int[countNum];
//将输入的数字放进数组中
for(int i = 0;i < countNum;i++){
toArray[i] = str.charAt(i);
}
//将数组中的数字进行0和1的变化
for(int j = 0;j < countNum;j++){
if(toArray[j] % 2 == 0){
toArray[j] = 0;
}else{
toArray[j] = 1;
}
}
//将数组调整回整数
int k = 0;
for(int l = 0;l < countNum;l++){
k = k * 10 + toArray[l];
}
System.out.println(k);
}
} import java.util.Scanner;
import java.util.Arrays;
public class Main{
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
Integer integer = scanner.nextInt();
String string = integer.toString();
int L = string.length();
int[] intArray = new int[L];
//把输入的数字存入数组中(下)
for(int i=0;i<L;i++){
intArray[i] = string.charAt(i);
}
//把数组中的数字变成0或1
for(int j=0;j<L;j++){
if(intArray[j]%2==0){
intArray[j]=0;
}else{
intArray[j]=1;
}
}
//把数组变成整数
int i=0;
for(int l=0;l<L;l++){
i = i*10+intArray[l];
}
System.out.print(i);
}
} import java.util.*;
public class Main{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
String s=input.nextLine();
int result[]=new int[s.length()]; //利用整形数组接收赋值
int output=0;
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='0'|s.charAt(i)=='2'|s.charAt(i)=='4'|s.charAt(i)=='6'|s.charAt(i)=='8'){
result[i]=0;//偶数赋0
}
else{
result[i]=1;//奇数赋1
}
}
for(int j=0;j<result.length;j++){//数组转整形
output=output*10+result[j];
}
System.out.print(output);
}
} import java.util.*;
public class Main{
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int sum = 0;
int flag = 1;
while (n != 0) {
if (n % 10 % 2 != 0) {
sum += 1 * flag;
}
n /= 10;
flag *= 10;
}
System.out.println(sum);
}
}