[SWEA][D1] 몫과 나머지 출력하기(JAVA)

반응형
[ 문제 ]
2개의 수 a, b를 입력 받아, a를 b로 나눈 몫과 나머지를 출력하는 프로그램을 작성하라.
import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		
        for(int i = 1; i<=T; i++) {
        	int a = sc.nextInt();
            int b = sc.nextInt();
            int div = a/b;
            int rmd = a%b;
            System.out.println("#"+i+" "+div+" "+rmd);
        }
	}
}

반응형