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

来源:互联网 发布:太原医院挂号软件 编辑:程序博客网 时间:2024/05/01 09:37

链接:

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;}


0 0
原创粉丝点击