재귀함수 썸네일형 리스트형 [Java] 정올기초다지기 함수3-자가진단03 12345678910111213141516171819202122232425package 함수3.자가진단03; import java.util.Scanner; public class Main { static int sum =0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); recursive(num); sc.close(); } public static void recursive(int num) { if(num == 0) { System.out.println(sum); return; } else { sum += num; recursive(num-1); } }} 더보기 [Java] 정올기초다지기 함수3-자가진단02 12345678910111213141516171819202122package 함수3.자가진단02; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); recursive(num); sc.close(); } public static void recursive(int num) { if(num == 0) { return; } else { System.out.print(num+" "); recursive(num-1); } }} > num를 먼저 출력한뒤, 재귀함수를 호출할때에 num-1을 해주어 num값.. 더보기 [Java] 정올기초다지기 함수3-자가진단01 1234567891011121314151617181920212223package 함수3.자가진단01; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num=0; num = sc.nextInt(); recursive(num); sc.close();} public static void recursive(int num) { if(num ==0) { return; } else { System.out.println("recursive"); recursive(num - 1); } }} > recursive라는 함수안에서 recursiv.. 더보기 이전 1 다음