반응형
[ 문제 ]
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);
}
}
}

반응형
'코딩테스트 > SW Expert Academy' 카테고리의 다른 글
| [SWEA][D1] N줄덧셈(JAVA) (0) | 2023.11.10 |
|---|---|
| [SWEA][D1] 대각선 출력하기(JAVA) (0) | 2023.11.10 |
| [SWEA][D1] 서랍의 비밀번호(JAVA) (0) | 2023.11.10 |
| [SWEA][D1] 스탬프 찍기 (0) | 2023.11.10 |
| [SWEA][D1] 신문 헤드라인(JAVA) (0) | 2023.11.10 |