본문 바로가기

Java/SWEA

[JAVA] SWEA 2029. 몫과 나머지 출력하기

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&contestProbId=AV5QGNvKAtEDFAUq&categoryId=AV5QGNvKAtEDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=JAVA&select-1=1&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

정답 

 

import java.util.Scanner;

class Solution
{
	public static void main(String args[]) throws Exception
	{	
		Scanner sc = new Scanner(System.in);
		
		int T = sc.nextInt();
		
		int num[] = new int[2];
		for(int t=1; t<=T; t++)
		{
			for(int i=0; i<num.length; i++)
			{
				num[i] = sc.nextInt();
			}
			
			System.out.printf("#%d %d %d\n",t,num[0]/num[1],num[0]%num[1]);
		}
	}
}

 

'Java > SWEA' 카테고리의 다른 글

[JAVA] SWEA 1938. 아주 간단한 계산기  (0) 2024.05.01
[JAVA] SWEA 2025. N줄덧셈  (0) 2024.05.01
[JAVA] SWEA 2043. 서랍의 비밀번호  (0) 2024.05.01
[JAVA] SWEA 2046. 스탬프 찍기  (0) 2024.05.01
[JAVA] SWEA 2547. 신문 헤드라인  (0) 2024.05.01