码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-05-12 15:43:58      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:c++   stl   

链接:

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


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

标签:c++   stl   

原文地址:http://blog.csdn.net/axuan_k/article/details/45669237

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!