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 ...
随机推荐
- trie树(字典树)的部分简单实现
什么是trie树(字典树)? trie树是一种用于快速检索的多叉树结构.和二叉查找树不同,在trie树中,每个结点上并非存储一个元素. trie树把要查找的关键词看作一个字符序列.并根据构成关键词字符 ...
- python国内镜像源
让python pip使用国内镜像 国内源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pyp ...
- JSON数据的缓存
前端有时候会遇到JSON数据的缓存,后台给我们JSON数据是一个对象,直接缓存起来它存的是字符串 "[object Object]".这是因为在缓存时会隐式调用toString方法 ...
- MongoDB系列二:MongoDB安装过程
一.MongoDB安装,以Linux系统安装为例:(下载:www.mongodb.org 注意使用stable版本) 1.下载最新版本的MongoDB安装包,wget http://fastdl.mo ...
- HTTP之缓存技术
1. 缓存简介 缓存是位于服务器和客户端的中间单元,主要根据用户代理发送过来的请求,向服务器请求相关内容后提供给用户,并保存内容副本,例如 HTML 页面.图片.文本文件或者流媒体文件.然后,当下一个 ...
- nginx 部署前端项目(vue)
前提:安装好nginx 打开nginx目录,一般是(/usr/local/nginx) npm run build 打好vue包 一般放到(/usr/local/nginx/html/)目录下 配置: ...
- Android__adb 命令大全
ADB 即 Android Debug Bridge,Android调试桥.ADB工作方式比较特殊,采用监听Socket TCP 端口的方式让IDE和Qemu通讯,默认情况下adb会daemon相关的 ...
- POJ 3083 -- Children of the Candy Corn(DFS+BFS)TLE
POJ 3083 -- Children of the Candy Corn(DFS+BFS) 题意: 给定一个迷宫,S是起点,E是终点,#是墙不可走,.可以走 1)先输出左转优先时,从S到E的步数 ...
- Elasticsearch 部署以及报错解决
前言 Elasticsearch 是一个非常值得学习和使用的分布式存储 此次部署将采用 centos6.9 一.初步了解 ES 简谈概念 Elasticsearch 是一个开源的高扩展的分布式全文检索 ...
- Mac下持续集成-自动发送邮件
找到下面这项填写邮件地址 注意下面绿色标记的邮箱要和上面的一致,否则会报错 如果两个绿色标记的邮箱不一致会报这样的错: ---------------------------------------- ...