+ α/알고리즘 문제풀이3 유클리드 호제법: 최대공약수 알고리즘(Java, Python) 두 자연수의 최대공약수를 구하는 알고리즘이다. 재귀함수를 사용한다. # 유클리드 호제법 A, B(자연수, A>B) 이고 A%B=R 일 때, gcd(A,B) = gcd(B,R) #Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public class gcd { public static int gcd(int a, int b) { if(a % b == 0) return b; else return gcd(b, a % b); } public static void main(String[] args) { int result = 0; result = gcd(192,162); System.out.println(result); } } Colored by Color Scripter cs .. 2021. 5. 14. [Java] 백준 2439_별찍기2 1234567891011121314151617181920import java.util.*;public class Main{ public static void main(String[] args){ int N=0; Scanner scan=new Scanner(System.in); N=scan.nextInt(); if(N=1) { for(int i=1;i 2020. 7. 1. [Java] 백준 2438번_별찍기1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import java.util.*; public class { public static void main(String[] args){ int N=0; Scanner scan=new Scanner(System.in); N=scan.nextInt(); if(N1) { for(int i=1;i 2020. 7. 1. 이전 1 다음