사자자리
[C++] 백준 10430번: 나머지 본문
https://www.acmicpc.net/problem/10430
10430번: 나머지
첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000)
www.acmicpc.net
#include<iostream>
using namespace std;
class mod{
private:
int a, b, c, result;
public:
void cal1(int, int, int);
void cal2(int, int, int);
void cal3(int, int, int);
void cal4(int, int, int);
void show();
mod();
};
mod::mod(){
}
void mod::cal1(int a, int b, int c){
result = (a + b) % c;
}
void mod::cal2(int a, int b, int c){
result = ((a % c) + (b % c)) % c;
}
void mod::cal3(int a, int b, int c){
result = (a * b) % c;
}
void mod::cal4(int a, int b, int c){
result = ((a % c) * (b % c)) % c;
}
void mod::show(){
cout << result << endl;
}
int main(){
int a, b, c;
cin >> a >> b >> c;
mod temp;
temp.cal1(a, b, c);
temp.show();
temp.cal2(a, b, c);
temp.show();
temp.cal3(a, b, c);
temp.show();
temp.cal4(a, b, c);
temp.show();
return 0;
}
'C++ > C++ 문제' 카테고리의 다른 글
[C++] 백준 11944번: NN (0) | 2022.08.24 |
---|---|
[C++] 백준 2920번: 음계 (0) | 2022.08.24 |
[C++] 백준 1308번: D-Day (0) | 2022.08.05 |
[C++] 백준 4673번: 셀프 넘버 (0) | 2022.08.03 |
[C++] 백준 10872번: 팩토리얼 (0) | 2022.08.03 |
Comments