QQ Account Management

 QQ Account Management

You are supposed to implement the functions of account "Log in" and "Register" for the most popular instant messager QQ. The most challenging part is that QQ now has more than a billion users.

Input Specification:

Each input file contains one test case. For each case, the first line contains an integer N (105) - the total number of queries. Then N lines follow, each contains a query in the format Command QQ_No Password where Command is either R (meaning to register a new account, and hence followed by a new account number and a password), or L (meaning to log in with an existing account, and hence followed by the account number and the password); QQ_No is an integer that is greater than 1000 and no more than 10 digits long; and Password is a string with no less than 6 and no more than 16 characters without any space.

Output Specification:

For each test case, print the corresponding message for each query in a line. The messages are:

  • If a new account is successfully registered, output "Register Successful";
  • If the new registering account number already exists, output "ERROR: Account Number Already Exists";
  • If log in successfully, output "Log in Successful";
  • If the log in account does not exist, output "ERROR: Account Not Exist";
  • If log in with a wrong password, output "ERROR: Wrong Password".

Sample Input:

5
L 1234567890 myQQ@qq.com
R 1234567890 myQQ@qq.com
R 1234567890 myQQ@qq.com
L 1234567890 myQQ@qq
L 1234567890 myQQ@qq.com

Sample Output:

ERROR: Account Not Exist
Register Successful
ERROR: Account Number Already Exists
ERROR: Wrong Password
Log in Successful

#include <iostream>
#include<cstdio>
#include<string>
#include<map>
#include<cstdlib>

using namespace std;



map<long long int,string> myq;

void judge_nopwd(long long int QQ_No,string password)
{
    string pwd=myq[QQ_No];
    if(pwd==password)
    {
        cout<<"Log in Successful"<<endl;
    }
    else
    {
        cout<<"ERROR: Wrong Password"<<endl;
    }
}
void judge_exist_L(long long int QQ_No,string password)
{
    if(myq.find(QQ_No)!=myq.end())
    {
        judge_nopwd(QQ_No,password);
    }
    else
    {
        cout<<"ERROR: Account Not Exist"<<endl;
    }
}
void judge_exist_R(long long int QQ_No,string password)
{
    if(myq.find(QQ_No)!=myq.end())
    {
        cout<<"ERROR: Account Number Already Exists"<<endl;
    }
    else
    {
        cout<<"Register Successful"<<endl;
        myq[QQ_No]=password;
    }
}
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        char Command;
        long long int QQ_No;
        string Password;

        cin>>Command>>QQ_No>>Password;
        if(Command=='L')
        {
            judge_exist_L(QQ_No,Password);
        }
        else if(Command=='R')
        {
            judge_exist_R(QQ_No,Password);
        }
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值