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 ...
随机推荐
- 人脸检测之Haar-like,Adaboost,级联(cascade)
最新版本整理完毕,见: http://face2ai.com/MachineLearning-Haar-like-Adaboost-cascade 0:写在前面的话 写在前面的牢骚 ...
- [Vue] : vue-resource 实现 get, post, jsonp请求
vue-resource 实现 get, post, jsonp请求 常见的数据请求类型:get,post,jsonp 除了vue-resource之外,还可以使用axios的第三方包实现实现数据的请 ...
- redis redis-cli
默认无权限控制: 远程服务连接: $ redis-cli -h 127.0.0.1 -p 6379 windows下 :redis-cli.exe -h 127.0.0.1 -p 6379 redis ...
- TCP报头格式
1.端口号:用来标识同一台计算机的不同的应用进程. 1)源端口:源端口和IP地址的作用是标识报文的返回地址. 2)目的端口:端口指明接收方计算机上的应用程序接口. TCP报头中的源端口 ...
- 报错1251 - Client does not support authentication protocol 解决办法
# 1.容器中登录mysql,查看mysql的版本 status; # 2,进行授权远程连接(注意mysql 8.0跟之前的授权方式不同) GRANT ALL ON *.* TO 'root'@'%' ...
- Flutter移动电商实战 --(3)底部导航栏制作
1.cupertino_IOS风格介绍 在Flutter里是有两种内置风格的: material风格: Material Design 是由 Google 推出的全新设计语言,这种设计语言是为手机.平 ...
- debian上搭建私有docker仓库
docker官方仓库是docker hub.虽然很好用,但是无法满足私密性的要求. 如果只需要在局域网内或者朋友圈内分享各自制作的image,那么,搭建属于自己的docker仓库变得很有必要. 一.环 ...
- visible,invisible和GONE的区别
在Android开发中,大部分控件都有visibility这个属性,其属性有3个分别为“visible ”.“invisible”.“gone”.主要用来设置控制控件的显示和隐藏.有些人可能会疑惑In ...
- manager 实现进程之间的数据共享 list dict
manager 能够实现进程之间的数据共享 (list,dict) 如果多个进程同事修改同一份共享数据,这个时候需要加锁,保证数据的准确性. (1) dict list 可以实现进程之间的数据共享 ( ...
- 一首好听的摇滚歌曲(Ever Dream),以及优美的译作
送上一首好听的摇滚歌曲,以及优美的译作.祝大家新年快乐.happy new year! [ti:Ever Dream][ar:Nightwish][al:Century Child][by:吖光] ...