1035. Password (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N (<= 1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.

Output Specification:

For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line "There are N accounts and no account is modified" where N is the total number of accounts. However, if N is one, you must print "There is 1 account and no account is modified" instead.

Sample Input 1:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa

Sample Output 1:

2
Team000002 RLsp%dfa
Team000001 R@spodfa

Sample Input 2:

1
team110 abcdefg332

Sample Output 2:

There is 1 account and no account is modified

Sample Input 3:

2
team110 abcdefg222
team220 abcdefg333

Sample Output 3:

There are 2 accounts and no account is modified

思路
水题,记录修改纠正过的密码就行。
代码
#include<iostream>
#include<vector>
using namespace std;
struct user
{
string id;
string password;
};
int main()
{
int N;
while(cin >> N)
{
vector<user> dic;
for(int i = 0;i < N;i++)
{
user tmp;
cin >> tmp.id >> tmp.password;
bool isModified = false;
for(int j = 0; j < tmp.password.size();j++)
{
if(tmp.password[j] == '1')
{
tmp.password[j] = '@';
isModified = true;
}
else if(tmp.password[j] == '0')
{
tmp.password[j] = '%';
isModified = true;
}
else if(tmp.password[j] == 'l')
{
tmp.password[j] = 'L';
isModified = true;
}
else if(tmp.password[j] == 'O')
{
tmp.password[j] = 'o';
isModified = true;
}
}
if(isModified)
{
dic.push_back(tmp);
}
}
if(dic.empty())
{
if( N == 1)
cout << "There is 1 account and no account is modified";
else
cout << "There are " << N <<" accounts and no account is modified";
}
else
{
cout << dic.size() << endl;
for(int i = 0;i < dic.size();i++)
{
cout << dic[i].id << " " << dic[i].password << endl;
}
}
}
}

  

PAT1035: Password的更多相关文章

  1. pat1035. Password (20)

    1035. Password (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...

  2. 打开程序总是会提示“Enter password to unlock your login keyring” ,如何成功关掉?

    p { margin-bottom: 0.1in; line-height: 120% } 一.一开始我是按照网友所说的 : rm -f ~/.gnome2/keyrings/login.keyrin ...

  3. your password has expired.to log in you must change it

    今天应用挂了,log提示密码过期.客户端连接不上. 打开mysql,执行sql语句提示密码过期 执行set password=new password('123456'); 提示成功,但客户端仍然连接 ...

  4. MySql Access denied for user 'root'@'localhost' (using password:YES) 解决方案

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入"mysql -uroot -pmyadmin"后出现以下错 ...

  5. [上架] iOS "app-specific password" 上架问题

    当你的 Apple ID 改用双重认证密码时,上架 iOS App 需要去建立一个专用密码来登入 Apple ID 才能上架. 如果使用 Application Loader 上传时,得到这个讯息: ...

  6. [LeetCode] Strong Password Checker 密码强度检查器

    A password is considered strong if below conditions are all met: It has at least 6 characters and at ...

  7. mysql 错误 ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number 解决办法

    MySQL创建用户(包括密码)时,会提示ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number: 问题原因: ...

  8. phpmyadmin #1045 - Access denied for user 'root'@'localhost' (using password: NO)

    phpmyadmin访问遇到1045问题 #1045 - Access denied for user 'root'@'localhost' (using password: NO) 解决办法 找到p ...

  9. 保留password模式文本框textbox内的数据不丢失。

    在asp.net 2.0环境下,使用textbox,提交到服务器再传回,如果textbox是password模式的,那么textbox内的密码(星号),就没有了! protected override ...

随机推荐

  1. Android增量升级的方法和原理

    总结: 我们使用delta编码算法减少Android应用升级程序的大小.我们通过bsdiff和bspatch工具在android上实现delta编码算法.服务器软件和android应用已经部署.当前, ...

  2. jsp中的tag与tld

    转载自: http://www.cnblogs.com/fanzi2009/archive/2010/04/08/1707888.html 在jsp文件中,可以引用tag和tld文件.  1.对于ta ...

  3. 安卓Eclipse开发者的福音

    我们知道,谷歌已经放弃对Eclipse(ADT)的维护更新了,现在官网上也找不到ADT的下载链接了,我们大多数同学仍在使用的ADT版本可能已经很老了,估计大多数的SDK版本只到4.4,而,在尝试升级以 ...

  4. Material Design之CollapsingToolbarLayout使用

    CollapsingToolbarLayout作用是提供了一个可以折叠的Toolbar,它继承至FrameLayout,给它设置layout_scrollFlags,它可以控制包含在Collapsin ...

  5. linux下用gtk+写比赛赌博GUI小游戏

    游戏界面全部由gtk的GUI完成,没有使用openGL之类的高端货. 游戏玩法就是8位选手比赛跑步,你可以在赛前赌哪位选手会赢,如果输了cash会被扣除,反之cash会增加. 无聊写了3个选项:小数时 ...

  6. hbase 集群管理脚本

    #!/bin/bash # Show all running Java processes on region servers. Must run on master using HBase owne ...

  7. javascript语言扩展:可迭代对象(2)

    在文章迭代器(1)中我们简单介绍了如何创建一个可迭代对象:出于某种考虑你可能想从可迭代对象中显式获取一个迭代器对象,这时你可以调用Iterator()函数(该函数是定义在JavaScript 1.7中 ...

  8. RubyMotion之父:Ruby是目前替代Objective-C的最佳iOS开发语言

    发表于2012-08-16 00:52| 21716次阅读| 来源CSDN| 24 条评论| 作者杨鹏飞 RubyMotionRubyObjective-CiOSJava 摘要:曾几何时,PC端有那么 ...

  9. 在Eclipse 中集成SVN

    在项目开发的过程中,我们需要用到版本控制工具,最常见的也就是SVN了,下面就来介绍最简单的一种在Elipse中集成svn工具. 第一步:下载 svn包,如site-1.6.5.zip或者site-1. ...

  10. Jedis对Redis的常用命令操作

    本篇主要总结一些Jedis对Redis的常用命令操作: 1.对key操作命令 2.对String操作命令 3.对List操作命令 4.对Set操作命令 5.对Hash操作命令 6.排序操作指令 一.项 ...