浙江大学PAT_甲级_1035. Password (20)

浙江大学pat题目集合(1001-1080) 浙江大学的程序能力测试(pat)上所有advanced级别的题目集合的更新版本,从1001到最新的1080全部都有。欢迎大家下载,平时放在pat或者手机上可以回顾回顾,思考思考,非常不错哦。 立即下载

题目链接:点击打开链接

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
注意事项:只检测一个密码且这个密码合格时输出:
There is 1 account and no account is modified
检测多个密码且密码全合格时输出:
There are 2 accounts and no account is modified
我的C++程序:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
bool is_1(char c)//如果字符是1
{
	return c == '1';
}
bool is_0(char c)//如果字符是0
{	
	return c == '0';
}
bool is_l(char c)//如果字符是l
{
	return c == 'l';
}
bool is_O(char c)//如果字符是O
{
	return c == 'O';
}
bool is_bad_pwd(string str)//判断密码是否含有 1,0,l,O中的字符,含有则返回1
{
	string pwd;
	pwd = str.substr(str.find(' ') + 1, str.size() - 1);
	if (pwd.find('1') == -1 && pwd.find('0') == -1 && pwd.find('l') == -1 && pwd.find('O') == -1)
	{
		return 0;
	}
	return 1;
}
void change_and_print(string str)
{
	string pwd;
	pwd = str.substr(str.find(' ') + 1, str.size() - 1);
	replace_if(pwd.begin(), pwd.end(), is_1, '@');//找到所有'1',并替换为'@'
	replace_if(pwd.begin(), pwd.end(), is_0, '%');//replace_if头文件<algorithm>
	replace_if(pwd.begin(), pwd.end(), is_l, 'L');
	replace_if(pwd.begin(), pwd.end(), is_O, 'o');
	cout <<str.substr(0,str.find(' ')+1)+pwd<<endl;//输出帐户名+空格+修改后的密码
}
int main()
{
	int n;
	int i = 0;
	string s,account,pwd;
	vector<string>str;
	int count_unfit= 0;//不合适的密码数量
	cin >> n;
	if (n == 0)
	{
		return 0;
	}
	for (i = 0;i <n;i++)
	{
		cin >> account >> pwd;//输入账户名和密码
		s = account +' '+ pwd;//帐户名+空格+密码合并为一个字符串
		str.push_back(s);//加入到vector
	}
	for (i = 0;i < n;i++)
	{
		if (is_bad_pwd(str[i]) == 1)//判断不合适的密码
			count_unfit++;//不合适的密码数量+1
	}
	if (count_unfit > 0)
		cout << count_unfit << endl;//输出不合适的密码数量
	for (i = 0;i <n;i++)
	{
		if (is_bad_pwd(str[i]) == 1)//如果是不合适的密码
			change_and_print(str[i]);//输出账号和修改后的密码
	}
	if (count_unfit==0)//如果密码全部合格
	{
		if(n==1)//密码全部合格,且只检测一个时
			printf("There is 1 account and no account is modified", n);
		else//多个账号和密码合格
			printf("There are %d accounts and no account is modified", n);
	}
	//system("pause");
	return 0;
}


浙江大学pat题目集合(1001-1091) 浙江大学的程序能力测试(pat)上所有advanced级别的题目集合的更新版本,从1001到最新的1091全部都有。纯手工制作,花了不少时间调整了格式以方便阅读,欢迎大家下载,平时放在pad或者手机上可以回顾回顾,思考思考。 当时我就是用它充实我闲余时间,作用显著,喜欢的童鞋不要错过! 立即下载

相关推荐

谷歌Gemini模型免费API调用全攻略:从注册到实战(附代码示例)

本文详细介绍了如何免费调用谷歌Gemini模型的API,从注册获取API密钥到实战应用的全过程。内容涵盖环境准备、基础API调用、多模态处理、高级功能及生产环境实践,帮助开发者高效利用Gemini模型进行代码生成和复杂任务处理。附有代码示例,适合AI开发者和技术爱好者。

weixin_29212429的博客 1673

PAT甲级1035Password(密码)详细题解C++

本题我们可以通过使用一个结构体存储变量,然后对密码进行暴力循环,从而判断是否有对应需要修改的字符,输出对应答案。需要注意最后输出的单数和复数形式,笔者在这里被坑惨了。

m0_56011305的博客 624

AD/Protel老手才知道的PCB过孔查看技巧:3分钟分清通孔、盲孔和埋孔

本文为PCB设计工程师提供了在Altium Designer/Protel中快速鉴别通孔、盲孔和埋孔的实用技巧。通过层叠管理器、高级筛选工具和实战五步法,帮助用户在3分钟内精准识别过孔类型,提升设计效率和电路性能。特别适合处理高密度HDI板卡中的复杂过孔布局。

weixin_29164497的博客 601

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

1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare for PAT, the judge sometimes has to

我不要写标题 827

DCN交换机通过boot模式升级

LIC导入成功后,输入enable进入特权模式,把网线接到通讯网口上,配置好对应interface vlan地址,在enable模式用 copy tftp://x.x.x.x/xxxxxx_nos.img nos.img待提示write ok时,reload设备完成升级。交换机启动后,在显示以下信息时输入“Ctrl+B”,一定得是手动按“Ctrl+B”进入的boot模式才能正常升级。升级交换机成功,在BootROM模式下,执行命令run或reboot,回到CLI配置界面。# 交换机通过boot模式升级。

m0_72501865的博客 960

豆包大模型API调用两种方法

ps: 因为是自用,所以这里图方便采用硬编码密钥的形式;如果有需求/安全风险,建议参考官方教程设置ARK_API_KEY环境变量的方式。坏处是:看别人的教程走了一大圈弯路hh;基础调用的话方法一就可以满足了,也比较方便快捷,容易上手。将 <Model> 替换为 Endpoint ID即可。创建就按照提示填写信息就行,需要实名认证,有免费额度。绿框框里就是Endpoint ID。

kkkkkkkkkasey的博客 1万+

pat-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...

欢迎访问方偲的博客 391

【强化学习】强化学习中,训练过程的稳定性是什么?该如何进行衡量?请详细进行解释

在强化学习中,训练过程的稳定性指的是算法在训练过程中表现出一致的行为,并且能够稳定地收敛到一个好的策略。收敛性:算法是否能够在有限的时间内收敛到一个近似最优的策略。鲁棒性:算法在不同的初始条件或环境扰动下的表现是否稳定。方差:算法在多次运行中表现出的变异程度。稳定的训练过程意味着算法的训练曲线平滑奖励信号变化小,且策略或价值函数的变化是渐进的。

wq6qeg88的博客 1636

【PAT甲级A1035】Password (20分)(c++)

1035 Password (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB 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 distingui

小庄同学的博客 197

Python爬虫实战:利用最新技术爬取B站视频信息

本文详细介绍了如何使用Python最新技术构建一个功能完善的B站视频信息爬虫。我们从基础爬取开始,逐步深入到反反爬策略、异步处理、数据存储和分析等高级主题。更智能的反反爬策略:使用机器学习识别验证码更高效的分布式架构:结合Kubernetes实现弹性伸缩实时数据管道:将爬取的数据实时推送到数据分析平台多平台支持:扩展支持抖音、YouTube等其他视频平台。

2201_76125261的博客 1047

UG\NX二次开发 获取对象的引用集

获取对象的引用集,一个对象可能有多个引用集,下面这个封装函数可以获取对象的所有引用集。

王牌飞行员_里海的博客 504

PAT甲级 1035 Password

GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT

邹九的个人博客 172

详解YOLOv5网络结构/数据集获取/环境搭建/训练/推理/验证/导出/部署

本文给大家带来的教程是利用YOLOv5训练自己的数据集,以及有关YOLOv5的网络结构讲解/数据集获取/环境搭建/训练/推理/验证/导出/部署相关的教程,同时通过示例的方式让大家来了解具体的操作流程,过程中还分享给大家一些好用的资源,我还对其中的参数进行了详细的讲解,通过本文大家可以成功训练自己的数据集,在开始之前给大家推荐一下我的YOLOv5专栏,本专栏包含上百种YOLOv5的改进机制以及如何撰写论文的教程,手把手教大家如何改进YOLOv5非常适合科研小白。

Snu77的博客 4916

PTA 甲级 1035 Password(C++)

pta 甲级 乙级 算法 小白 刷题

m0_71946666的博客 143

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

1035 Password(20 分)

思路分析: 用STL库里的string类型数组存储输入字符串; string *str2 = new string[n];根据输入n的大小指定str2的大小,当然也可用; vector&lt;string&gt; v; #include &lt;string&gt; #include&lt;iostream&gt; using namespace std; char judge(char ...

qq_38677031的博客 427

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

PAT 甲级1035 Password(模拟)

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 distingu...

zpjlkjxy的博客 372

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

【PAT 甲级】1035 Password (20 分)

1035Password(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 distingu...

CrystalXueNing的博客 259

PAT甲级1035 Password

题目 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 distin...

领导的博客 318

PAT甲级1035

1035 Password (20 point(s))   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 ...

云胡的博客 414

PAT A1035

为了准备 PAT,评判系统有时必须对用户生成随机密码。问题是经常有一些困惑的密码很难去辨别 数字 1 还是 小写字母 L,或者 数字 0 还是 大写字母O,一个解决方案就是 把 数字 1 换成 @,数字 0 换成 %,小写 l 换成大写 L,大写 O 换成小写 o,现在你的工作就是去写一个程序检查系统产生的账户,然后帮助系统修改令人困惑的密码 输入格式: 每个输入文件包含一个测试用例。每个用例...

gengsj 333

PAT甲级 1035 Password (20point(s))

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 ...

Seqlist_base的博客 216

1035. Password (20)【字符串处理】——PAT (Advanced Level) Practise

题目信息1035. Password (20)时间限制400 ms 内存限制65536 kB 代码长度限制16000 BTo prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing

1199

PAT甲级 1035 Password (20 分) 题解

\quad字符串处理题,分别判断密码有没有需要修改的字符,按要求修改后统计修改的数量,然后就是按照要求输出即可。 #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; string change(string ...

qq_40438165的博客 1439

PAT A1035 Password (20分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520 题目描述 To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that ther...

Rhao的博客 184
上一篇: 浙江大学PAT_甲级_1031. Hello World for U (20)
下一篇: 浙江大学PAT_甲级_1036. Boys vs Girls (25)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址