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
思路
  • 用结构体表示数据,如果密码需要修改的就放到结构体数组里,最后根据修改的数量和n的大小来决定输出
代码
#include<bits/stdc++.h>
using namespace std;
struct user
{
string id;
string password;
}a[1010];
int a_num = 0;
int main()
{
int n;
cin >> n;
string id, ps;
bool modify = false;
for(int j=0;j<n;j++)
{
cin >> id >> ps;
modify = false; //表示有无修改过
for(int i=0;i<ps.size();i++)
{
if(ps[i] == '1')
{
modify = true;
ps[i] = '@';
}else
if(ps[i] == '0')
{
modify = true;
ps[i] = '%';
}else
if(ps[i] == 'l')
{
modify = true;
ps[i] = 'L';
}else
if(ps[i] == 'O')
{
modify = true;
ps[i] = 'o';
}
}
if(modify)
{
a[a_num].id = id;
a[a_num++].password = ps;
}
}
if(a_num == 0)
if(n != 1)
printf("There are %d accounts and no account is modified", n);
else
printf("There is 1 account and no account is modified");
else
{
cout << a_num<< endl;
for(int i=0;i<a_num;i++)
{
cout << a[i].id << " " << a[i].password;
cout << endl;
}
}
return 0;
}
引用

https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520

PTA (Advanced Level)1035.Password的更多相关文章

  1. PAT (Advanced Level) 1035. Password (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  2. PTA(Advanced Level)1036.Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  3. PTA (Advanced Level) 1004 Counting Leaves

    Counting Leaves A family hierarchy is usually presented by a pedigree tree. Your job is to count tho ...

  4. PTA (Advanced Level) 1020 Tree Traversals

    Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. Given the ...

  5. PTA (Advanced Level) 1010 Radix

    Radix Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? ...

  6. PTA(Advanced Level)1025.PAT Ranking

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  7. PTA (Advanced Level) 1009 Product of Polynomials

    1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomial ...

  8. PTA (Advanced Level) 1008 Elevator

    Elevator The highest building in our city has only one elevator. A request list is made up with Npos ...

  9. PTA (Advanced Level) 1007 Maximum Subsequence Sum

    Maximum Subsequence Sum Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous su ...

随机推荐

  1. Luogu P5022 旅行 搜索+贪心

    好吧...一直咕..现在才过...被卡常卡到爆... 写的垃圾版本,$n^2$无脑删边..可以发现走出来的是棵树...更优秀的及数据加强版先咕着...一定写.qwq #include<cstdi ...

  2. Appium进阶教程

    Monkey的使用 adb shell monkey -p com.lqr.wechat -v 500 > monkey.log adb shell monkey -p com.lqr.wech ...

  3. Linux+CLion+树莓派远程编译时,Cmake编译出现undefined reference to 'pthread_create'的解决办法

    在CLion中开发讯飞的linux语音库时编译出现以下问题: undefined reference to 'pthread_create' CLion的cmake配置:修改CMakeLists.tx ...

  4. jQuery的入口函数

    原生的JS的入口函数指的是:window.onload = function(){}: 如下所示: //原生js的入口函数.页面上所有内容加载完毕, 才执行.//不仅要等文本加载完毕, 而且要等图片也 ...

  5. 简易总结react-hook三大基础

    react-hook的最重要的三大基础 import { useEffect, useState, useContext } from 'react' 1.每一个简单的一句话总结 useEffect ...

  6. PHP AJAX 返回XML数据

    例子:利用AJAX间接访问数据库,查出Nation表中的数据,返回XML数据,并将Nation表中的数据显示在下拉列表框中 外层建一个下拉列表框 </select> JQurey代码 $( ...

  7. Fast R-CNN论文阅读摘要

    论文链接: https://arxiv.org/pdf/1504.08083.pdf 代码下载: https://github.com/rbgirshick/fast-rcnn Abstract Co ...

  8. Kbengine游戏引擎-【1】kbengine安装

    本文主要介绍如何在Linux上安装 官网环境要求:Centos >= 5.x, Debian >= 5.x GCC版本: >= 4.4.x 官网链接 本文的安装环境介绍:Centos ...

  9. Repeater, DataList, 和GridView的区别及使用

    从对象层次图可以看出,Repeater是最轻最小的控件,它仅仅继承了基本控件的功能,包括ID属性.子控件集合等.另一方面,DataList和DataGrid则继承了WebControl功能,包括样式和 ...

  10. LuceneUtil使用反射,封装通用的方法

    package loaderman.util; import java.io.File; import java.lang.reflect.Method; import loaderman.entit ...