"SWEA 2029 몫과 나머지 출력하기"의 두 판 사이의 차이

 
1번째 줄: 1번째 줄:
==개요==
==개요==
;SWEA 2029 몫과 나머지 출력하기
{{SWEA|난이도=1}}
* 난이도: [[SWEA D1]]
* a를 b로 나눈 몫(a/b)과 a를 b로 나눈 나머지(a%b)를 출력한다.
* a를 b로 나눈 몫(a/b)과 a를 b로 나눈 나머지(a%b)를 출력한다.



2023년 8월 25일 (금) 01:41 기준 최신판

1 개요[ | ]

SWEA 2029 몫과 나머지 출력하기

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    for(int tc=1; tc<=T; tc++) {
        int a, b;
        cin >> a;
        cin >> b;
        cout << "#" << tc << " " << a/b << " " << a%b << endl;
    }
}

3 Java[ | ]

import java.util.Scanner;
class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for(int t=1; t<=T; t++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.format("#%d %d %d\n", t, a/b, a%b);
        }
    }
}

4 Python[ | ]

#kcy
k = int(input())
for i in range(0, k):
    a, b = map(int, input().split())
    print("#%d" % (i+1), end=' ')
    print(int(a/b), a%b)
T = int(input())
for tt in range(T):
    a, b = map(int, input().split())
    print( "#%d %d %d" % (tt+1, a//b, a%b) )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}