P5266 【深基17.例6】学籍管理

#include <bits/stdc++.h>

using namespace std;
int n;
string name;
int opt, score;

unordered_map<string, int> _map;

int main() {
    cin >> n;
    while (n--) {
        cin >> opt;
        switch (opt) {
            case 1:
                cin >> name >> score;
                _map[name] = score;
                cout << "OK" << endl;
                break;
            case 2:
                cin >> name;
                if (_map.count(name) > 0) cout << _map[name] << endl;
                else cout << "Not found" << endl;
                break;
            case 3:
                cin >> name;
                if (_map.count(name) > 0) _map.erase(name), cout << "Deleted successfully" << endl;
                else cout << "Not found" << endl;
                break;
            case 4:
                cout << _map.size() << endl;
                break;
        }
    }
    return 0;
}

P5266 【深基17.例6】学籍管理

上一篇:Git 最核心命令行操作


下一篇:redis 模糊删除脚本