1035 Password (20 分)

密码混淆与修正
本文介绍了一个程序设计问题,旨在解决由于数字和字母相似性引起的密码混淆。通过将易混淆的字符如1、0、l、O替换为@、%、L、o,从而增强密码的可读性和区分度。文章提供了代码示例,展示了如何实现这一功能。

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

 细节:

#include <iostream>
#include <string>
#include <vector>	
#include <queue>

using namespace std;

struct password
{
	string id, pw;
};



int modify(string &s)
{
	int count = 0;
	for (auto &c : s)
	{
		switch (c)
		{
		default:
			count++;  //如果count的值和s的长度相同  即没有改变其中的某个字符
			break;
		case '1':
			c = '@';
			break;
		case '0':
			c = '%';
			break;
		case 'l':
			c = toupper(c);
			break;
		case 'O':
			c = tolower(c);
			break;
		}
	}
	return count;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int n, finalcount = 0;
	cin >> n;
	vector<password> p(n);
	queue<int> m;  //用来统计哪个字符串改了   输出的时候得知道输出哪个
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].id >> p[i].pw;
	}
	for (int i = 0; i < n; i++)
	{
		if (modify(p[i].pw) != p[i].pw.length())
		{
			m.push(i); //第几个改了  把它的下标存起来
			finalcount++;
		}
	}
	if (!finalcount) //没有改
	{
		
		/*这是最先想到的写法    这种其实就是考验你的细节  细心
		if (n == 1)   //n=1输出写“1 account”  不是1的话 得加s  “accounts” 还有 is和are的区别 坑爹啊  看柳婼代码 迅速意识到了这个细节
		{
			cout << "There is 1 account and no account is modified" << endl;
		}
		else
		{
			cout << "There are" << " " << n << " accounts and no account is modified" << endl;
		}*/



		//第二种写法   从c++ primer 上看到的
		cout << "There " << (n == 1 ? "is " : "are ") << n
			<< (n == 1 ? " account" : " accounts") << " and no account is modified" << endl;
	}
	else
	{
		cout << finalcount << endl;
		while (!m.empty())
		{
			cout << p[m.front()].id << " " << p[m.front()].pw << endl;
			m.pop();
		}
	}
	//fclose(stdin);
	return 0;
}

 

标题SpringBoot智能在线预约挂号系统研究AI更换标题第1章引言介绍智能在线预约挂号系统的研究背景、意义、国内外研究现状及论文创新点。1.1研究背景与意义阐述智能在线预约挂号系统对提升医疗服务效率的重要性。1.2国内外研究现状析国内外智能在线预约挂号系统的研究与应用情况。1.3研究方法及创新点概述本文采用的技术路线、研究方法及主要创新点。第2章相关理论总结智能在线预约挂号系统相关理论,包括系统架构、开发技术等。2.1系统架构设计理论介绍系统架构设计的基本原则和常用方法。2.2SpringBoot开发框架理论阐述SpringBoot框架的特点、优势及其在系统开发中的应用。2.3数据库设计与管理理论介绍数据库设计原则、数据模型及数据库管理系统。2.4网络安全与数据保护理论讨论网络安全威胁、数据保护技术及其在系统中的应用。第3章SpringBoot智能在线预约挂号系统设计详细介绍系统的设计方案,包括功能模块划、数据库设计等。3.1系统功能模块设计划系统功能模块,如用户管理、挂号管理、医生排班等。3.2数据库设计与实现设计数据库表结构,确定字段类型、主键及外键关系。3.3用户界面设计设计用户友好的界面,提升用户体验。3.4系统安全设计阐述系统安全策略,包括用户认证、数据加密等。第4章系统实现与测试介绍系统的实现过程,包括编码、测试及优化等。4.1系统编码实现采用SpringBoot框架进行系统编码实现。4.2系统测试方法介绍系统测试的方法、步骤及测试用例设计。4.3系统性能测试与析对系统进行性能测试,析测试结果并提出优化建议。4.4系统优化与改进根据测试结果对系统进行优化和改进,提升系统性能。第5章研究结果呈现系统实现后的效果,包括功能实现、性能提升等。5.1系统功能实现效果展示系统各功能模块的实现效果,如挂号成功界面等。5.2系统性能提升效果对比优化前后的系统性能
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值