http://pat.zju.edu.cn/contests/pat-practise/1035

本文介绍了一个用于检查并修改易混淆密码的程序。该程序能够将容易混淆的字符如1(one)替换为@、0(zero)替换为%等,并且能够处理多个账户的密码修改。文章提供了具体的输入输出样例及实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1035. Password (20)
时间限制
400 ms
内存限制
32000 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


[cpp]  view plain copy
  1. #include <iostream>  
  2. #include <string>  
  3. #include <algorithm>  
  4. #include <memory.h>  
  5. #include <cstdio>  
  6. #include <cstdlib>  
  7. #include <vector>  
  8. using namespace std;  
  9. #define MAX 0Xfffffff  
  10.   
  11. int main(){  
  12.   
  13.   //freopen("in.txt", "r", stdin);  
  14.   
  15.   int n;  
  16.   char name[20];  
  17.   char p[20];  
  18.   vector<string> res;  
  19.   cin>>n;  
  20.    
  21.   for(int i=0;i<n;++i){  
  22.     scanf(" %s %s", name, p);  
  23.     int len = strlen(p);  
  24.     bool flag = false;  
  25.     for(int j=0;j<len;++j){  
  26.         switch(p[j]){  
  27.         case '1':p[j]='@';flag=true;break;  
  28.         case '0':p[j]='%';flag=true;break;  
  29.         case 'l':p[j]='L';flag=true;break;  
  30.         case 'O':p[j]='o';flag=true;break;  
  31.         }  
  32.     }  
  33.     if(flag){  
  34.         string sn = name;  
  35.         string sp = p;  
  36.         string s = sn+" "+sp;  
  37.         res.push_back(s);  
  38.     }  
  39.   }  
  40.   if(res.size()==0){  
  41.     if(n==1)  
  42.         printf("There is 1 account and no account is modified\n");  
  43.     else  
  44.         printf("There are %d accounts and no account is modified\n", n);  
  45.   }else{  
  46.     printf("%d\n", res.size());  
  47.     for(int i=0;i<res.size();++i)  
  48.         cout<<res[i]<<endl;  
  49.   }  
  50.   
  51.      
  52.    //fclose(stdin);  
  53. }     
──(root㉿xcs)-[/home/xcs/桌面] └─# gpg --show-keys /etc/apt/trusted.gpg.d/kali-archive-keyring.gpg gpg: 目录‘/root/.gnupg’已创建 gpg: 钥匙箱‘/root/.gnupg/pubring.kbx’已创建 pub rsa4096 2025-04-17 [SC] [有效至:2028-04-17] 827C8569F2518CC677FECA1AED65462EC8D5E4C5 uid Kali Linux Archive Automatic Signing Key (2025) <devel@kali.org> ┌──(root㉿xcs)-[/home/xcs/桌面] └─# apt update 错误:1 http://mirrors.aliyun.com/kali kali-rolling InRelease 403 Forbidden [IP: 124.225.96.42 80] 命中:2 http://http.kali.org/kali kali-rolling InRelease 获取:3 http://http.kali.org/kali kali-rolling/main i386 Packages [20.4 MB] 获取:4 http://http.kali.org/kali kali-rolling/main i386 Contents (deb) [47.7 MB] 获取:5 http://http.kali.org/kali kali-rolling/contrib i386 Packages [97.1 kB] 获取:6 http://http.kali.org/kali kali-rolling/contrib i386 Contents (deb) [183 kB] 获取:7 http://http.kali.org/kali kali-rolling/non-free i386 Packages [147 kB] 获取:8 http://mirrors.neusoft.edu.cn/kali kali-rolling/non-free i386 Contents (deb) [859 kB] 错误: 无法下载 http://mirrors.aliyun.com/kali/dists/kali-rolling/InRelease 403 Forbidden [IP: 124.225.96.42 80] 错误: 仓库 “http://mirrors.aliyun.com/kali kali-rolling InRelease” 没有数字签名。 注意: 无法安全地用该源进行更新,所以默认禁用该源。 注意: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 ┌──(root㉿xcs)-[/home/xcs/桌面] └─#
最新发布
07-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值