您的位置:首页 > 其它

PAT QQ帐户的申请与登陆 STL-MAP的应用

2015-05-12 14:34 525 查看
链接:

QQ帐户的申请与登陆

#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int main()
{
    int n;
    char ch;
    string str1,str2;
    map<string,string>mapp;
    map<string,string>::iterator ii;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        cin>>ch>>str1>>str2;
        ii=mapp.find(str1);
        if(ch=='N')
        {
            if(ii==mapp.end())
            {
                cout<<"New: OK"<<endl;
                mapp[str1]=str2;
            }
            else
                cout<<"ERROR: Exist"<<endl;
        }
        else if(ch=='L')
        {
            if(ii==mapp.end())
                cout<<"ERROR: Not Exist"<<endl;
            else if(ii->first.compare(str1)==0)
            {
                if(ii->second.compare(str2)==0)
                    cout<<"Login: OK"<<endl;
                else
                    cout<<"ERROR: Wrong PW"<<endl;
            }
        }
    }
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: