Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication12;
- import java.util.Scanner;
- import java.util.Stack;
- /**
- {
- * @author Lenovo1
- */
- public class JavaApplication12 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner in = new Scanner(System.in);
- Stack<Integer> stack = new Stack<Integer>();
- System.out.println("Adj be egy binaris szamot! ");
- int num = in.nextInt();
- if (num < 256 && num > 0)
- {
- while (num != 0)
- {
- int d = num % 2;
- stack.push(d);
- num /= 2;
- }
- System.out.print("\nBinarisan ez:");
- while (!(stack.isEmpty() ))
- {
- System.out.print(stack.pop());
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement