DESCRIPTIONTop-Left 모서리에서 Bottom-Right 모서리까지 장애물을 피해서 이동하는데 필요한 최소 이동횟수를 구하라. 8*8 판 . 길 X 장애물 (Create a maze) Write a program that will find a path in a maze, as shown in Figure 18.13a. The maze is represented by an 8 * 8 board. The path must meet the following conditions:The path is between the upper-left corner cell and the lower-right corner cell in the maze.The program enables the user to pl..
DESCRIPTION(String permutation) Write a recursive method to print all the permutations of a string. For example, for the string abc, the permuation is 입력된 문자열의 모든 순서를 출력하는 프로그램을 recursive method 로 작성하시오. 예를들어, abc 문자열이 입력되면 abc, acb, bac, bca, cab, cba 을 출력해야한다.INPUTLine 1 : 랜덤한 길이의 문자열OUTPUTLine 1 ~ 길이! : 각 문자열 순열SAMPLE INPUTABCD SAMPLE OUTPUTABCD ABDC ACBD ACDB ADBC ADCB BACD BADC BCAD BCDA BD..
DESCRIPTION(피보나치 숫자들) 반복문을 이용하여 18.2에 나열된 메소드를 다시 작성하시오. 즉, 반복문을 이용하여 피보나치 수열을 구하시오. (Fibonacci numbers) Rewrite the fib method in Listing 18.2 using iterations. INPUT* Line 1 : 테스트 케이스 T (1~1,000) * Line 2 ~ T+1 : n (1~20)OUTPUT* Line 1 ~ T : fib(n) SAMPLE INPUT3 2 9 18SAMPLE OUTPUT1 34 2584HINT힌트 : 재귀호출 없이 fib(n)를 계산하려면, fib(n-2)와 fib(n-1)을 먼저 계산하여야 한다. f0과 f1을 전전항과 전항의 피보나치 숫자라고 하자. 구하고자 하는 피..
DESCRIPTION10.9절에서 소개된 BigInteger 클래스를 이용하면 큰 숫자에 대한 팩토리얼을 구할 수 있다 (이를테면, 100!). 팩토리얼 함수를 재귀호출을 이용해서 구현하시오. (그러나, 단순 재귀 호출로는 fail. 메모화를 활용) Using the BigInteger class introduced in Section 10.9, you can find the factorial for a large number (e.g., 100!). Implement the factorial method using recursion. Write a program that prompts the user to enter an integer and displays its factorial.INPUT* Lin..
DESCRIPTION사용자가 실수를 입력하면 분수로 바꿔주는 프로그램을 작성하시오. 힌트 : 실수를 string으로 읽을 때, 정수부분과 소수부분으로 나누고 Rational 클래스의 BigInteger를 사용해서 소수를 유리수 형식(a/b)으로 쓰세요. (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the BigI..
DESCRIPTION분모와 분자를 BigInteger로 사용하는 Rational 클래스를 구현하시오. (Use BigInteger for the Rational class) Redesign and implement the Rational class in Listing 13.13 using BigInteger for the numerator and denominator.INPUT* Line 1 : 테스트케이스의 개수 N * Line 2 ~ N+1 : 각 케이스 별 숫자 a b c dOUTPUT* Line 1 ~ 4N : 각 테스트 케이스마다 다음과 같이 4줄씩 출력 - Line 1 : a/b + c/d = 결과 - Line 2 : a/b - c/d = 결과 - Line 3 : a/b * c/d = 결과 -..
DESCRIPTIONhowToColor() method를 가지고 이름이 Colorable인 interface를 디자인하시오. Colorable을 구현하고 GeometricObject에 기능을 추가한 Square, Rectangle 클래스를 디자인 하시오. howtocolor method는 howToColor: xxx을 출력 해야 합니다. (The Colorable interface) Design an interface named Colorable with a void method named howToColor(). Every class of a colorable object must implement the Colorable interface. Design a class named Square that ..
DESCRIPTIONGeometricObject를 비교할 수 있도록 Comparable 인터페이스를 구현하고, 주어진 두 개의 GeometricObject 객체 중 더 큰 객체를 반환하는 정적 메소드 max 를 정의하시오. (Enable GeometricObject comparable) Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects. INPUTLine 1 : 문자열의 개수 N Line 2 ~ 1+N : radius colo..