解题代码
#include<iostream>
#include<string>
#include<map>
using namespace std;
map<string, string> m;
int main()
{
int N;
cin >> N;
char c;
string num, code;
for (int i = 0; i < N; i++) {
cin >> c >> num >> code;
if (c == 'N') {
if (m[num] == "") {
m[num] = code;
cout << "New: OK" << endl;
}
else cout << "ERROR: Exist" << endl;
}
else {
if (m[num] == "") cout << "ERROR: Not Exist" << endl;
else {
if (m[num] == code) cout << "Login: OK" << endl;
else cout << "ERROR: Wrong PW" << endl;
}
}
}
return 0;
}
测试结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/0ae5779d7dadf9fce9c14de7e9b927c9.png)
问题整理
1.基础题。