Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lab2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int num = Integer.parseInt(scanner.nextLine());
- String s1 = "1";
- if(num%2==0) {
- s1 += "" + "0";
- }
- else if(num%2!=0) {
- s1 += "" + "1";
- }
- while(num/2!=0) {
- num/=2;
- s1 += "" + num%2;
- }
- int before = Integer.parseInt(s1);
- String s2 = "";
- int change = 0;
- while(before!=1) {
- s2 += "" + before%10;
- before/=10;
- change--;
- }
- System.out.println(s2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement