PAT A1035 Password (20)
AC代码
- 注意创造函数条件中使用引用
- 输出语句注意单复数
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
struct Usr {
bool flag;
char id[20];
char pwd[20];
}usr[1010];
void modify(Usr& a) { //参数使用了引用&,可以对传入参数进行修改
for(int i = 0; i < 10; i++) {
char b = a.pwd[i];
if(b == '1') {
a.pwd[i] = '@';
a.flag = 0;
}
if(b == '0') {
a.pwd[i] = '%';
a.flag = 0;
}
if(b == 'l') {
a.pwd[i] = 'L';
a.flag = 0;
}
if(b == 'O') {
a.pwd[i] = 'o';
a.flag = 0;
}
}
}
void init_flag(Usr& a) {
a.flag = 1;
}
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n;
scanf("%d", &n); //输入密码数量
for(int i = 0; i < n; i++) {
scanf("%s %s", usr[i].id, usr[i].pwd);
}
// for(int i = 0; i < n; i++) {
// printf("%s %s\n", usr[i].id, usr[i].pwd);
// }
// printf("------------------------------\n");
int num = 0; //需要修改的密码数量
//初始化flag
for(int i = 0; i <= n; i++) {
init_flag(usr[i]);
// printf("init:%s %s %d\n", usr[i].id, usr[i].pwd, usr[i].flag);
modify(usr[i]);
// printf("%s %s %d\n", usr[i].id, usr[i].pwd, usr[i].flag);
if(usr[i].flag == 0) {
num++;
}
}
// printf("------------------------------\n");
// for(int i = 0; i < n; i++) {
// printf("%s %s %d\n", usr[i].id, usr[i].pwd, usr[i].flag);
// }
// printf("------------------------------\n");
// printf("%d\n", num);
if(num != 0) {
printf("%d\n", num);
for(int i = 0; i <= n; i++) {
if(usr[i].flag == 0) {
printf("%s %s\n", usr[i].id, usr[i].pwd);
}
}
} else if(n == 1){
printf("There is %d account and no account is modified", n);
} else if(n > 1) {
printf("There are %d accounts and no account is modified", n);
}
return 0;
}
PAT A1035 Password (20)的更多相关文章
- A1035 Password (20)(20 分)
A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords f ...
- PAT A1035 Password
题目描述: To prepare for PAT, the judge sometimes has to generate random passwords for the users. The pr ...
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- pat1035. Password (20)
1035. Password (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...
- pat 1035 Password(20 分)
1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...
- PAT甲级——1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- 【PAT】1035. Password (20)
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...
- PAT Advanced 1035 Password (20 分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
随机推荐
- Django从Models 10分钟定制一个Admin后台
目录 Django从Models 10分钟建立一套RestfulApi Django从Models 10分钟定制一个Admin后台 简介 Django自带一个Admin后台, 支持用户创建,权限配置和 ...
- php 一段 shmop
$size = 1024*1024; $shm_key = ftok(__FILE__, 't'); $shm_id = shmop_open($shm_key, "c", 064 ...
- Codeforces Round #371 (Div. 2)
之前做过E题,是一个DP. A题,水题,两线段求交集. B题,set一下判断即可. C题,水题.但是我写麻烦了,直接转化成二进制再做,比用字符串relize()以后再map要好写得多. D题,交互题, ...
- nc浏览器的十宗罪
1.收藏夹.nc浏览器收藏夹无法导出或者导出困难,十分恶心.其他的小众软件都有这个简单的功能,某天我突然想到为什么手机nc浏览器连个导出收藏夹的功能都没有,并不是不注重用户体验,或则导功能很难实现不会 ...
- 服务器多进程powershell导致服务器瘫痪问题解决
1.公司服务器多次无法访问,经查多由于开启了多个powershell进程,网上查询是被挖矿了,可通过将powershell应用程序重命名解决. 2.然而重命名的时候发现需要trustedInstall ...
- js动态往对象里边添加一项
第一种方法let obj ={"name":"tom","age":16}let key = "id";let valu ...
- k8s-helm01-----helm基本使用
什么是helm Helm 是 Kubernetes 生态系统中的一个软件包管理工具. 基础概念: Helm:客户端,主要负责管理本地的 Charts.repositories 以及与tiller服务器 ...
- .net 分布式锁实现
摘要: .net分布式锁,包括redis分布式锁和zookeeper分布式锁的.net实现. 分布式锁在解决分布式环境下的业务一致性是非常有用的. 分布式锁 经常用于在解决分布式环境下的业务一致性和协 ...
- 004-Spring boot 快速入门-项目搭建与启动、SpringBootApplication、启动图标
一.官方地址 Spring:http://spring.io/ Spring Project:http://spring.io/projects Spring boot:https://project ...
- AcitveReocrd事件和关联操作
ActiveRecord预定义的事件,都在 yiidbBaseActiveRecord 中进行了明确: abstract class BaseActiveRecord extends Model ...