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)的更多相关文章

  1. A1035 Password (20)(20 分)

    A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords f ...

  2. PAT A1035 Password

    题目描述: To prepare for PAT, the judge sometimes has to generate random passwords for the users. The pr ...

  3. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  4. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  5. pat1035. Password (20)

    1035. Password (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...

  6. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  7. PAT甲级——1035 Password (20分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  8. 【PAT】1035. Password (20)

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...

  9. PAT Advanced 1035 Password (20 分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

随机推荐

  1. Depth from Videos in the Wild 解读

    2019年7月17日11:37:05 论文 Depth from Videos in the Wild: Unsupervised Monocular Depth Learning from Unkn ...

  2. POJ 1741 Tree ——(树分治)

    思路参考于:http://blog.csdn.net/yang_7_46/article/details/9966455,不再赘述. 复杂度:找树的重心然后分治复杂度为logn,每次对距离数组dep排 ...

  3. ORA-28000

    oracle11g中默认设置了 “FAILED_LOGIN_ATTEMPTS=10次”,当输入密码错误次数达到设置值将导致此,该用户会自动锁住. 1. conn sys/oracle as sysdb ...

  4. Laravel 配置

    首页 问答社区 中文文档 API Composer Github 配置说明 框架下载好了,但是想要很好的使用,可能我们还有一些东西需要知道,这就是配置.和项目有关的配置是在 app/config 文件 ...

  5. 焦虑的 BAT、不安的编程语言,揭秘程序员技术圈生存现状!

    [程序人生编者按]在迭代不休的技术圈中,仅在过去的一个月期间,我们见证了有史以来第一张黑洞照片的诞生:经历了为让人义愤填膺的 996:思考了作为程序员的年龄之槛:膜拜了技术大神的成长历程:追逐了如编程 ...

  6. yum异常: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

    http://people.centos.org/hughesjr/chromium/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 ...

  7. js判断是否联网

    // navigator.onLine if (navigator.onLine){ //正常工作 console.log("在线状态............................ ...

  8. 02 MySQL之数据表的基本操作

    01-创建数据表 # 切换数据库 use test_db; # 创建数据表 语法规则如下: create table 表名 ( 字段名1, 数据类型 [列级别约束条件] [默认值], 字段名2, 数据 ...

  9. VBA ListView控件使用实例

    功能:ListView控件实现连接数据库实现显示查询数据空能. 图片: 代码: Private Sub CommandButton1_Click() Dim res As String res = T ...

  10. xshell一些简单的使用---1

    1.下载本地window中 2.在sftp模式下输入:put会打开xshell下载到window的位置目录