Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- C++
- Linux
- ros
- LeetCode
- 토픽
- 오늘도 우라라 공략
- while
- mariaDB
- JungOl
- MSG
- 리눅스
- 오늘도 우라라 펫 공략
- 데이터 베이스
- 등차수열
- Subscribe
- install opencv-4.4.0 on ubuntu 22.04
- publish
- ubuntu
- C언어
- 환경설정
- 프로그래밍
- 오늘도 우라라
- 오늘도 우라라 펫
- 마리아 DB
- mysql
- 우분투
- 반복문
- 기초
- topic
- 그랑사가
Archives
- Today
- Total
하루의 쉼터
[사칙연산] 10869. 사칙연산 - C++ 본문
반응형
| 10869. 사칙연산
Category :
입출력과 사칙연산
Title :
10869. 사칙연산
Rank :
Bronze
Language :
C++
Question :
두 자연수 A와 B가 주어진다.
이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.
Condition :
Input
두 자연수 A와 B가 주어진다. (1 ≤ A, B ≤ 10,000)
Output
첫째 줄에 A+B, 둘째 줄에 A-B, 셋째 줄에 A*B, 넷째 줄에 A/B, 다섯째 줄에 A%B를 출력한다.
Code :
#include<iostream>
class cl_solution{
private :
int fn_add(int a, int b);
int fn_sub(int a, int b);
int fn_mul(int a, int b);
int fn_div(int a, int b);
int fn_rem(int a, int b);
public :
void fn_run(int a, int b);
};
int cl_solution::fn_add(int a, int b){
return a+b;
}
int cl_solution::fn_sub(int a, int b){
return a-b;
}
int cl_solution::fn_mul(int a, int b){
return a*b;
}
int cl_solution::fn_div(int a, int b){
return a/b;
}
int cl_solution::fn_rem(int a, int b){
return a%b;
}
void cl_solution::fn_run(int a, int b){
std::cout << fn_add(a, b) << std::endl;
std::cout << fn_sub(a, b) << std::endl;
std::cout << fn_mul(a, b) << std::endl;
std::cout << fn_div(a, b) << std::endl;
std::cout << fn_rem(a, b) ;
}
int main() {
cl_solution* sol = new cl_solution();
int a = 0, b = 0;
std::cin >> a;
std::cin >> b;
sol->fn_run(a, b);
delete sol;
return 0;
}
BackJoon :
https://www.acmicpc.net/problem/10869
10869번: 사칙연산
두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.
www.acmicpc.net
GitHub :
GitHub - Anchangun/BaekJoon
Contribute to Anchangun/BaekJoon development by creating an account on GitHub.
github.com
반응형
'Coding Test > BaekJoon' 카테고리의 다른 글
[기초수학] 1193. 분수찾기 - C++ (0) | 2022.01.11 |
---|---|
[사칙연산] 10430. 나머지 - C++ (0) | 2022.01.11 |
[사칙연산] 1008. A/B - C++ (0) | 2022.01.11 |
[사칙연산] 10998. AxB - C++ (0) | 2022.01.11 |
[BAEKJOON] 1001. A-B - C++ (0) | 2022.01.07 |
Comments