Skip to content

Instantly share code, notes, and snippets.

@Oraindrop
Oraindrop / woowa.md
Last active January 29, 2019 05:50

1

  • 문자열로 된 이진수를 입력받아, 아래의 규칙에 따라 0으로 만드는 횟수를 출력하는 프로그램

    • 짝수일 경우 나누기 2를 한다 (8 -> 4)
    • 홀수일 경우 빼기 1을 한다 (7 -> 6)
    • 이진수는 0으로 시작할 수도 있다 (ex 011000)
  • ex) "011100" 입력

    • 십진수 28
      1. 28 / 2 -> 14
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
public class DynamicArrayTest {
@Test
public void init() {
DynamicArray<Integer> da = new DynamicArray<>();
assertEquals(0, da.size());
public interface DynamicArrayADT<E> {
int size();
void set(int index, E value);
E get(int index);
E remove(int index);
}
public class DynamicArray<E> {
private static final int DEFAULT_SIZE = 10;
private int size;
private Object[] arr;
public DynamicArray() {
this.size = 0;
this.arr = new Object[DEFAULT_SIZE];
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body onload = main()>
<script>