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
| #include <iostream>
using namespace std;
int main() {
int dollar;
int chocolate;
int coupon;
int addChocolate;
cout << "소지 금액 입력: " << endl;
cin >> dollar;
chocolate = dollar;
coupon = dollar;
while (coupon >= 7) {
addChocolate = coupon / 7; // 7쿠폰당->1초콜렛 교환
chocolate += addChocolate;
coupon = coupon % 7; // 교환 후 남은쿠폰
coupon += addChocolate; // 새로운 초콜렛에 포함된 쿠폰
}
cout << "초콜렛 " << chocolate << "개" << endl;
cout << "쿠폰 " << coupon << "개" << endl;
return 0;
}
|
댓글
댓글 쓰기