Advertisement
taweesoft

Untitled

Sep 7th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Lab2 {
  3.  
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int num = Integer.parseInt(scanner.nextLine());
  7. String s1 = "1";
  8.  
  9. if(num%2==0) {
  10. s1 += "" + "0";
  11. }
  12. else if(num%2!=0) {
  13. s1 += "" + "1";
  14. }
  15. while(num/2!=0) {
  16. num/=2;
  17. s1 += "" + num%2;
  18. }
  19. int before = Integer.parseInt(s1);
  20. String s2 = "";
  21. int change = 0;
  22. while(before!=1) {
  23. s2 += "" + before%10;
  24. before/=10;
  25. change--;
  26. }
  27. System.out.println(s2);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement