https://www.acmicpc.net/problem/10833
#include <iostream>
using namespace std;
class School {
int student;
int apple;
public:
void setStudent(int student) { this->student = student; }
void setApple(int apple) { this->apple = apple; }
};
int main() {
int num;
cin >> num;
School *sp = new School[num];
int student;
int apple;
int left;
int sum = 0;
for (int i = 0; i < num; i++) {
cin >> student >> apple;
sp[i].setStudent(student);
sp[i].setApple(apple);
left = apple % student;
sum += left;
}
cout << sum;
}
문제 해설
학교 클래스에 학생 수, 사과의 수를 표현하는 student, apple 멤버 변수를 만들고,
그 변수들을 초기화하기 위한 set 멤버 함수들을 구현하였다.
'Coding > 백준 온라인 저지 (Baekjoon Online Judge)' 카테고리의 다른 글
백준 온라인 저지 (Baekjoon Online Judge) - 10809번 : 알파벳 찾기 (0) | 2019.10.14 |
---|---|
백준 온라인 저지 (Baekjoon Online Judge) - 9325번 : 얼마? (0) | 2019.10.14 |
백준 온라인 저지 (Baekjoon Online Judge) - 16479번 : 컵라면 측정하기 (0) | 2019.10.14 |
백준 온라인 저지 (Baekjoon Online Judge) - 1085번 : 직사각형에서 탈출 (0) | 2019.10.13 |
백준 온라인 저지 (Baekjoon Online Judge) - 11441번 : 합 구하기 (0) | 2019.07.12 |