//本题的测试点:
//测试点0:题目中所给出的输入输出样例;
//测试点1:最大表,全部新申请,密码16位;
//测试点2:注册或登录的账号不只有一个,解决方法是需要定义两个map容器,一个是对注册过的账号进行标记,另一个是使不同的账号对应不同或相同的密码的密码;

中文:
7-39 QQ账户管理(25分)

您应该实现帐户“登录”和“注册”的功能,为最流行的即时通讯器QQ。最具挑战性的部分是QQ现在拥有超过10亿的用户。

输入规格:

每个输入文件包含一个测试用例。对于每种情况,第一行包含一个整数n(≤10

5

—查询总数。接下来是n行,每行包含一个格式为命令qq_no password的查询,其中命令为r(意味着注册一个新帐户,随后是一个新帐户号和一个密码)或l(意味着用现有帐户登录,然后是帐户号和密码);qq_no是一个整数,大于t汉1000,长度不超过10位;密码为不少于6个字符、不超过16个字符的字符串,无空格。

输出规格:

对于每个测试用例,在一行中为每个查询打印相应的消息。信息包括:

如果新帐户注册成功,输出“注册成功”;

如果新注册账号已经存在,输出“错误:账号已经存在”;

如果登录成功,输出“登录成功”;

如果登录账号不存在,输出“错误:账号不存在”;

如果使用错误密码登录,则输出“错误:错误密码”。

样本输入:

电话:1234567890 myqq@qq.com

R 1234567890,邮箱:myqq@qq.com

R 1234567890,邮箱:myqq@qq.com

l 1234567890我的qq@qq

电话:1234567890 myqq@qq.com

样品输出:

错误:帐户不存在

注册成功

错误:帐号已存在

错误:密码错误

登录成功
英文:
7-39 QQ Account Management (25 分)
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 (≤10
​5
​​ ) - 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<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#include<map>
map<int,int>h;
map<int,string>h1;
int main()
{int n,i,number,t;char ch2[1000],ch;cin>>n;for(i=0;i<n;i++){getchar();scanf("%c %d %s",&ch,&number,&ch2);if(ch=='R')//注册新账号;{if(number>1000&&number<=10000000000&&h[number]= =0){t=strlen(ch2);if(t>=6&&t<=16){printf("Register Successful\n");h[number]=1;//对已经注册过的账号进行标记为1;h1[number]=ch2;//记录下这个账号所对应的密码;}else {printf("ERROR: Wrong Password\n");}}else if(h[number]= =1){printf("ERROR: Account Number Already Exists\n");}}else if(ch=='L'){if(h[number]==1){if(h1[number]==ch2){printf("Log in Successful\n");}else printf("ERROR: Wrong Password\n");}else printf("ERROR: Account Not Exist\n");}}return 0;
}

7-39 QQ Account Management (25 分)【c++】【中英文】相关推荐

  1. # 7-15 QQ帐户的申请与登陆 (25 分)

    7-15 QQ帐户的申请与登陆 (25 分) 实现QQ新帐户申请和老帐户登陆的简化版功能.最大挑战是:据说现在的QQ号码已经有10位数了. 输入格式: 输入首先给出一个正整数N(≤10^5​ ),随后 ...

  2. 7-11 名人堂与代金券 (25 分)

    7-11 名人堂与代金券 (25 分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习"数据结构"课程的学生,想要获得一张合格证书,总评成绩必 ...

  3. 【CCCC】L2-027 名人堂与代金券 (25分),模拟水题

    problem L2-027 名人堂与代金券 (25分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习"数据结构"课程的学生,想要获得一张合 ...

  4. 天梯赛 L2-027 名人堂与代金券 (25 分)

    L2-027 名人堂与代金券 (25 分) 思路: 大体上就是 vector结合结构体储存学生信息,再跑一下自定义排序, 最后在输出上面卡了一下,索性最后还是解决了输出问题 对于在中国大学MOOC(h ...

  5. 12门课100分直博清华!这份成绩单冲上热搜,但学霸小伙也曾考过25分

    点击上方"视学算法",选择加"星标"或"置顶" 重磅干货,第一时间送达 金磊 明敏 发自 凹非寺 量子位 报道 | 公众号 QbitAI 一 ...

  6. 1121 Damn Single (25 分)

    1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is bei ...

  7. [PTA]L2-001 紧急救援 (25 分)

    L2-001 紧急救援 (25 分) Description 作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图.在地图上显示有多个分散的城市和一些连接城市的快速道路.每个城市的救援队数量和每 ...

  8. 1067 Sort with Swap(0, i) (25 分)

    1067 Sort with Swap(0, i) (25 分) Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy ...

  9. 【PAT乙】1080 MOOC期终成绩 (25分)

    problem 1080 MOOC期终成绩 (25分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习"数据结构"课程的学生,想要获得一张合格 ...

最新文章

  1. 27.3. source code
  2. 获取java hashCode分布
  3. mongodb给我们提供了fsync+lock机制把数据暴力的刷到硬盘上
  4. 杭电1232 畅通工程
  5. SSL四次握手的过程
  6. django如何给上传的图片重命名(给上传文件重命名)
  7. GARFIELD@04-02-2005
  8. 毕业设计之 ----基于微信小程序的商城购物系统
  9. ad10搜索快捷键_AD 常用快捷键
  10. 请和我一起学习机器学习算法(高斯混合聚类)
  11. 宏基因组数据分析:差异分析(LEfSe安装使用及LDA score计算)
  12. android投影到创维电视,创维电视怎么投屏?图文讲解安卓和苹果手机投屏到创维电视方法...
  13. 数字IC后端知识扫盲——OCV(上)
  14. 请你谈谈TCP协议与UDP协议的区别
  15. 如何将二维码巧妙放进海报里?
  16. KITTI数据集--参数
  17. 打败你的不是现实,是时间管理|互联网时代的时间管理术
  18. 区块链中的全节点与轻量级节点
  19. 码云上比较好的java项目
  20. outlook 日历 桌面_将Microsoft Outlook固定到桌面背景

热门文章

  1. git 新建分支并推送(push)到远程仓库
  2. linux谷歌浏览器运行安软件下载,Linux CentOS 下安装谷歌浏览器(Chromium)
  3. 高三学子,乘风破浪~
  4. 领扣 327 计算距离和
  5. PyTorch ImageNet 基于预训练六大常用图片分类模型的实战
  6. 利用python-opencv对LED数码管显示数字进行有效识别
  7. 微信小程序官方示例 Demo 代码
  8. python numpy 旋转90度
  9. Python 字符串与数字之间的转换
  10. DOC2PDF项目博客