码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • PAT甲级--1035 Password


    题目详情 - 1035 Password (pintia.cn)

    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:

    1. 3
    2. Team000002 Rlsp0dfa
    3. Team000003 perfectpwd
    4. Team000001 R1spOdfa

    Sample Output 1:

    1. 2
    2. Team000002 RLsp%dfa
    3. Team000001 R@spodfa

    Sample Input 2:

    1. 1
    2. team110 abcdefg332

    Sample Output 2:

    There is 1 account and no account is modified
    

    Sample Input 3:

    1. 2
    2. team110 abcdefg222
    3. team220 abcdefg333

    Sample Output 3:

    There are 2 accounts and no account is modified

     测试点分析:

    测试点1:

    当没有需要修改的时:

    N = 1时输出

    There is 1 account and no account is modified
    

    N > 1时输出:

    There is N account and no account is modified
    

    代码:

    1. #include
    2. using namespace std;
    3. int main()
    4. {
    5. int N, cnt = 0;
    6. cin >> N;
    7. string name, pass;
    8. vector ans;
    9. for (int i = 0; i < N; ++i) {
    10. cin >> name >> pass;
    11. int flag = 0;
    12. for (int j = 0; j < pass.size(); ++j) {
    13. if (pass[j] == '1') { pass[j] = '@'; flag = 1; }
    14. if (pass[j] == '0') { pass[j] = '%'; flag = 1; }
    15. if (pass[j] == 'l') { pass[j] = 'L'; flag = 1; }
    16. if (pass[j] == 'O') { pass[j] = 'o'; flag = 1; }
    17. }
    18. if (flag) {
    19. ans.push_back(name + " " + pass);
    20. cnt++;
    21. }
    22. }
    23. if (cnt == 0) {
    24. if (N == 1) { cout << "There is 1 account and no account is modified"; }
    25. else { cout << "There are " << N << " accounts and no account is modified"; }
    26. }
    27. else {
    28. cout << cnt << endl;
    29. for (int i = 0; i < cnt; ++i) {
    30. cout << ans[i] << endl;
    31. }
    32. }
    33. return 0;
    34. }

  • 相关阅读:
    数据库系统原理与应用教程(082)—— MySQL 系统数据库分析 —— information_schema
    Spring组件注入注意事项之一
    【汇编】“转移”综述、操作符offset、jmp指令
    私服下载失败,下载不下来
    element plus 切换页面报错‘emitsOptions‘和‘insertBefore‘
    web前端期末大作业 html+css古诗词主题网页设计
    看到《苍兰诀》结局的克隆人,让我想起了Java对象浅拷贝与深拷贝,于是赶至此文。
    HackTheBox Ambassador 枚举获得用户shell,git consul API提权
    注解在Java中有什么用?请给出示例
    Python 环境构建最佳实践:Mamba + Conda + PIP
  • 原文地址:https://blog.csdn.net/weixin_68051436/article/details/125882543
  • 最新文章
  • 【JVM】编译执行与解释执行的区别是什么?JVM 使用哪种方式?
    用 Hashids 优雅解决 C 端自增 ID 暴露问题
    V8引擎 精品漫游指南--Ignition篇(上) 指令 栈帧 槽位 调用约定 内存布局 基础内容
    LLVM Pass快速入门(四):代码插桩
    milkup:桌面端 markdown AI续写和即时渲染
    基于项目工程构建SBOM(软件物料清单)的研究
    鸿蒙应用开发UI基础第二节:鸿蒙应用程序框架核心解析与实操
    .NET 中如何快速实现 List 集合去重?
    扣子Coze实战:从0到1打造抖音+小红书热点监控智能体
    浅谈数据访问层
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号