#include <iostream>
using namespace std;

class Account {
public:
    string name;
    int balance = 0;

    void deposit(int m) {
        balance += m;
    }

    void withdraw(int m) {
        if (m > balance) {
            balance = 0;
        } else {
            balance -= m;
        }
    }
};

int main() {
    Account acc[3];

    for (int i = 0; i < 3; i++) {
        cin >> acc[i].name;
    }

    for (int i = 0; i < 3; i++) {
        int transactions;
        cin >> transactions;

        for (int j = 0; j < transactions; j++) {
            char type;
            int a;
            cin >> type >> a;
            if (type == 'd') {
                acc[i].deposit(a);
            } else if (type == 'w') {
                acc[i].withdraw(a);
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        cout << "예금주 이름: " << acc[i].name << endl;
        cout << "잔액: " << acc[i].balance << "원" << endl;
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: