C# 그리디 알고리즘 (Greedy 탐욕) 예시 간단 구현


C# 그리디 알고리즘 (Greedy 탐욕) 예시 간단 구현

코드 작성 using System; class GreedyAlgorithm { public static void Main() { int[] 동전 = { 500, 100, 50, 10 }; // 동전의 가치 int 거스름돈 = 1230; // 거슬러줘야 할 금액 Console.WriteLine("거스름돈: " + 거스름돈 + "원"); Console.WriteLine("동전 개수:"); for (int i = 0; i < 동전.Length; i++) { int 동전개수 = 거스름돈 / 동전[i]; 거스름돈 %= 동전[i]; Console.WriteLine(동전[i] + "원: " + 동전개수 + "개"); } } }


원문링크 : C# 그리디 알고리즘 (Greedy 탐욕) 예시 간단 구현