"SWEA 1938 아주 간단한 계산기"의 두 판 사이의 차이

잔글 (Jmnote님이 SWEA-1938 아주 간단한 계산기 문서를 SWEA 1938 아주 간단한 계산기 문서로 이동했습니다)
 
(사용자 3명의 중간 판 11개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;SWEA-1938 아주 간단한 계산기
{{SWEA|난이도=1}}
 
* 더하기(a+b), 빼기(a-b), 곱하기(a*b), 나누기(a/b) 결과를 차례로 출력한다.
==테스트케이스==
{{소스헤더|표준입력}}
<source lang='text'>
8 3
</source>
{{소스헤더|표준출력}}
<source lang='text'>
11
5
24
2
</source>


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
int main() {
int main() {
     int a, b;
     int a, b;
     cin >> a >> b;
     cin >> a >> b;
     cout << a+b << endl;
     cout << a+b << endl;
     cout << a-b << endl;
     cout << a-b << endl;
30번째 줄: 15번째 줄:
     cout << a/b << endl;
     cout << a/b << endl;
}
}
</source>
</syntaxhighlight>


==Java==
==Java==
<source lang='java'>
<syntaxhighlight lang='java'>
import java.util.Scanner;
import java.util.Scanner;
class Solution {
class Solution {
     public static void main(String args[]) {
     public static void main(String args[]) {
41번째 줄: 25번째 줄:
         int a = sc.nextInt();
         int a = sc.nextInt();
         int b = sc.nextInt();
         int b = sc.nextInt();
         System.out.println(a+b);
         System.out.println(a+b);
         System.out.println(a-b);
         System.out.println(a-b);
48번째 줄: 31번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>
 
==Python==
<syntaxhighlight lang='python'>
#kcy
a, b = map(int, input().split())
print(a+b)
print(a-b)
print(a*b)
print(int(a/b))
</syntaxhighlight>
<syntaxhighlight lang='python'>
a, b = map(int, input().split())
print(a+b)
print(a-b)
print(a*b)
print(a//b)
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[SWEA-2025 N줄덧셈]]
* [[SWEA 2025 N줄덧셈]]
* [[SWEA-2046 스탬프 찍기]]
* [[SWEA 2046 스탬프 찍기]]
* [[SWEA-2072 홀수만 더하기]]
* [[SWEA 2072 홀수만 더하기]]
* [[SWEA-2071 평균값 구하기]]
* [[SWEA 2071 평균값 구하기]]
 
==참고==
* https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PjsYKAMIDFAUq
 
[[분류: SWEA]]
[[분류: C++]]
[[분류: Java]]

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

1 개요[ | ]

SWEA 1938 아주 간단한 계산기

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
    cout << a-b << endl;
    cout << a*b << endl;
    cout << a/b << endl;
}

3 Java[ | ]

import java.util.Scanner;
class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);
    }
}

4 Python[ | ]

#kcy
a, b = map(int, input().split())
print(a+b)
print(a-b)
print(a*b)
print(int(a/b))
a, b = map(int, input().split())
print(a+b)
print(a-b)
print(a*b)
print(a//b)

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}