Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package asda;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- interface Stack<E>
- {
- public void push(E element);
- public E pop();
- public E peek();
- public boolean isFull();
- public boolean isEmpty();
- public void clear();
- }
- class ArrayStack<E> implements Stack
- {
- int depth;
- int size;
- E elems[];
- public ArrayStack(int size)
- {
- this.size = size;
- elems = (E[]) new Object[size];
- depth = 0;
- }
- @Override
- public void push(Object element) {
- E pom = (E) element;
- elems[depth++] = pom;
- }
- @Override
- public Object pop() {
- E pom = elems[--depth];
- elems[depth]=null;
- return pom;
- }
- @Override
- public Object peek() {
- return elems[depth-1];
- }
- @Override
- public boolean isFull() {
- return depth == size;
- }
- @Override
- public boolean isEmpty() {
- return depth ==0;
- }
- @Override
- public void clear() {
- for(int i=0;i<depth;i++)
- {
- elems[i] = null;
- }
- depth = 0;
- }
- }
- public class Asda {
- public static void main(String[] args) throws IOException{
- ArrayStack<Byte> magacin =new ArrayStack<>(32);
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- int N = Integer.parseInt(stdin.readLine());
- while(N>0)
- {
- magacin.push(N%2);
- N = N/2;
- }
- while(!magacin.isEmpty())
- {
- System.out.print(magacin.pop());
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement