PAT (Advanced Level) Practice 1035 Password (20 分)
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 (≤), 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 <algorithm>
- #include <set>
- #include <string>
- #include <cstring>
- using namespace std;
- struct node
- {
- string s1,s2;
- int num;
- }a[];
- int main()
- {
- int n;
- while(cin>>n){
- for(int i=;i<n;i++){
- cin>>a[i].s1>>a[i].s2;
- a[i].num=;
- }
- int sum=;
- for(int i=;i<n;i++){
- int flag=;
- for(int j=;j<a[i].s2.length();j++){
- if(a[i].s2[j]==''){
- flag=;
- a[i].s2[j]='%';
- }else if(a[i].s2[j]==''){
- a[i].s2[j]='@';
- flag=;
- }
- else if(a[i].s2[j]=='O'){
- a[i].s2[j]='o';
- flag=;
- }
- else if(a[i].s2[j]=='l'){
- a[i].s2[j]='L';
- flag=;
- }
- }
- if(flag){
- sum++;
- a[i].num=flag;
- }
- }
- if(sum>){
- cout<<sum<<endl;
- for(int i=;i<n;i++){
- if(a[i].num==){
- cout<<a[i].s1<<" "<<a[i].s2<<endl;
- }
- }
- }
- else if(n==) cout<<"There is "<<n<<" account and no account is modified"<<endl;
- else if(n>||n==) cout<<"There are "<<n<<" accounts and no account is modified"<<endl;
- }
- return ;
- }
PAT (Advanced Level) Practice 1035 Password (20 分)的更多相关文章
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) (模拟)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
- PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642
PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642 题目描述: Given any string of N (≥5) ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642
PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642 题目描述: Notice that the number ...
随机推荐
- Spring整合EasyExcel【基础设计】
前言 Java解析.生成Excel比较有名的框架有Apache poi.jxl.但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题,但POI ...
- H5谷歌登录 webview错误
接入谷歌登录 H5接入谷歌登录打包apk使用webview谷歌登录不上(谷歌不支持用户代理被归类为嵌入式用户代理(也称为网络视图),因此不允许向Google发出OAuth授权请求) 解决办法:替换ua ...
- vue中子组件触发父组件的方法
网上找了几种方法,下面这两种最实用,最明了 方法一:父组件方法返回是字符串或数组时用这种方法 子组件: <template> <button @click="submit& ...
- 我不知道的js(一)作用域与闭包
作用域与闭包 作用域 什么是作用域 作用域就是一套规则,它负责解决(1)将变量存在哪儿?(2)如何找到变量?的问题 作用域工作的前提 谁赋予了作用域的权利?--js引擎 传统编译语言编译的过程 分词/ ...
- js—数字那些事儿
进制之间互相转化 a=133 十进制转成其他进制 a.toString(num) a.toString(2); //转化成二进制,返回"10000101" a.toString(8 ...
- SQL Server 2019 表无法修改问题
SQL Server 2019 表无法修改问题 问题描述: 解决方法: 1.在菜单栏中,点击工具->选项,示例: 2.在选项中单击设计器->表设计器和数据库设计器->取消勾选阻止保存 ...
- 有哪些「看似复杂,实则简单」的 PS 技巧?
Mac版ps2019哪里有?本次主要以组合键为主,PS中隐藏功能都是通过这些“组合技”启动的,据统计熟练地使用一系列组合技会让你的效率提升30%(纯属虚构).其中一些比较难理解的我都制作了GIF动态图 ...
- P1613 跑路【倍增】【最短路】
题目描述 小A的工作不仅繁琐,更有苛刻的规定,要求小A每天早上在6:00之前到达公司,否则这个月工资清零.可是小A偏偏又有赖床的坏毛病.于是为了保住自己的工资,小A买了一个十分牛B的空间跑路器,每秒钟 ...
- 使用placeholder属性设置input文本框的提示信息
input文本框中设置提示信息,可以使用placeholder属性 <!DOCTYPE html> <html> <head> <meta charset=& ...
- Q函数和值函数
Q函数:奖励和 总奖励是在状态st采取行为at的奖励的期望和 值函数:奖励和 总奖励是在状态st下获得的奖励的期望和 下面是值函数另外的定义,在at行为下采取策略的Q函数的期望 是RL的目标函数,我理 ...