본문 바로가기
1일 1알고/알고리즘 재활 프로젝트

SWEA 1970. 쉬운 거스름돈 (Java)

by yeong. 2021. 12. 7.

 

.

package week2;

import java.util.Scanner;

public class Solution_쉬운거스름돈 {
	
	static int TC, N;
	static int[] numbers;
	static int[] money= {50000, 10000, 5000, 1000, 500, 100, 50, 10};
	
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		TC=sc.nextInt();
		
		for(int tc=1; tc<=TC;tc++) {
			N=sc.nextInt();
			numbers=new int[8];
			
			for(int i=0;i<money.length;i++) {
				numbers[i]=N/money[i];
				N=N%money[i];
			}
			
			System.out.println("#"+tc);
			for(int i=0;i<money.length;i++) {
				System.out.print(numbers[i]+" ");
			}System.out.println();
		}// end tc
	}

}