본문 바로가기

알고리즘 문제 풀이38

(Power JAVA) p83 - 1번 문제 하나의 상자에 오렌지를 10개씩 담을 수 있다. 오렌지가 127개 있다면 상자가 몇 개가 필요한가? 또 몇개의 오렌지가 남는가? --- 입력 값 --- 오렌지의 개수를 입력하시오: 127 --- 출력 값 --- 12박스가 필요하고 7개가 남습니다. import java.util.Scanner; public class Practice1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("오렌지의 개수를 입력 하세요: "); int orangeCount = sc.nextInt(); int extraOrange = orangeCount % 10; int box = orangeCount.. 2022. 2. 22.
별 찍기 - 10(2447) import java.util.Scanner; public class Main { static char array[][]; public static void main(String[] args) { Scanner inputValue = new Scanner(System.in); int N = inputValue.nextInt(); array = new char[N][N]; star(N, 0, 0, false); StringBuilder sb = new StringBuilder(); // 단순 출력문 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { sb.append(array[i][j]); } sb.append('\n'); } System.out.p.. 2022. 1. 23.
재귀함수 재귀함수에서 유의 해야할 점은 당연한 소리지만 호출한 함수로 계속 return 된다는 점이다(주석 참고) public class maxValue { public static void main(String[] args) { int arr[] = {6, 0, 20, 60, 40, 80, 100, 88, 24}; System.out.println("최대값= " + SortFunc(arr, arr.length)); } public static int SortFunc(int[] arr, int n) { int x; if(n == 1) { return arr[0]; } else { x = SortFunc(arr, n - 1); // 요기로 Return System.out.println("x=" + x); Syste.. 2022. 1. 20.
(2446)별 찍기 -9 (자바) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner inputValue = new Scanner(System.in); int number = inputValue.nextInt(); for (int i=1; i 2022. 1. 19.
(2445)별 찍기 -8 (자바) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner inputValue = new Scanner(System.in); int n =inputValue.nextInt(); for (int i = 1; i 2022. 1. 19.
(2444)별 찍기 - 7 (자바) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner inputValue = new Scanner(System.in); int Number = inputValue.nextInt(); for(int i=0; i 2022. 1. 18.
(2443)별 찍기 - 6 (자바) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner inputValue = new Scanner(System.in); int Number = inputValue.nextInt(); // int 5 입력 예정 for(int i=0; i 2022. 1. 18.
(2442)별 찍기 - 5 (자바) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner InputValue = new Scanner(System.in); int Number = InputValue.nextInt(); InputValue.close(); for(int i=1; i 2022. 1. 18.
반응형