l960. 星期幾? 5/16/2025

解法一、map

✅ 完整代碼

評分結果(參考) : AC (2ms, 344KB)

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;

    unordered_map<string, int> um = {
        {"Sunday", 0},
        {"Monday", 1},
        {"Tuesday", 2},
        {"Wednesday", 3},
        {"Thursday", 4},
        {"Friday", 5},
        {"Saturday", 6},
    };

    if(um.count(s)) cout << um[s];
    else cout << "error";

    return 0;
}