Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include<map>
- using namespace std;
- int main() {
- int age;
- cin >> age;
- double mashinePrice, toyPrice;
- cin >> mashinePrice >> toyPrice;
- double sum = 0;
- int toyCount = 0;
- int birthdayCash = 0;
- for (int i = 1; i <= age; i++) {
- if (i % 2 == 0) {
- birthdayCash += 10;
- sum += birthdayCash - 1;
- }
- else {
- toyCount++;
- }
- }
- sum += toyCount * toyPrice;
- cout.setf(ios::fixed);
- cout.precision(2);
- if (sum >= mashinePrice) {
- cout << "Yes! " << sum - mashinePrice << endl;
- }
- else {
- cout << "No! " << mashinePrice - sum << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement