解法:
1.先将对应的字符串存入map。
2.然后将输入的串的second置为空。
3.输出6-n,输出map中的非空串。
代码:
#include <bits/stdc++.h> using namespace std; typedef long long ll; map <string,string> m; int main(){ m["purple"] = "Power"; m["green"] = "Time"; m["blue"] = "Space"; m["orange"] = "Soul"; m["red"] = "Reality"; m["yellow"] = "Mind"; int n; cin >> n; int t = n; while(n--){ string s; cin >> s; m[s] = ""; } cout << 6-t << endl; for(auto t:m){ if(t.second != ""){ cout << t.second << endl; } } return 0; }