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. umei-spider

    umei-spider 1 #!/usr/bin/python3 2 3 import requests 4 from bs4 import BeautifulSoup 5 from contextl ...

  2. 【模板】强连通分量和tarjan算法

    看了好久才终于明白了这个算法..复杂度是O(n+m). 我觉得这个算法不是很好理解,但是看懂了以后还是觉得听巧妙的. 下面给出模板代码和三组简单数据帮助理解. 代码如下: #include <s ...

  3. CSS子元素在父元素中水平垂直居中的几种方法

    1. 水平居中(margin: auto;)子父元素宽度固定,子元素上设置 margin: auto; 子元素不能设置浮动,否则居中失效. #div1{ width: 300px; height: 3 ...

  4. Ubuntu 16.04 一键安装P4开发环境记录

    写在最前 P4开发环境安装可采用陈翔同学的一键安装脚本:p4Installer p4c-bm是P4-14的编译器,p4c是现在主流P4-16的编译器,bmv2是支持P4运行的软件交换机 系统环境 在安 ...

  5. springMVC课程笔记(二)springMVC组件配置

    1.springMVC的DispatcherServlet前段控制器配置,如下图所示在web.xml中配置如下内容: 2.在spring配置文件中,配置处理器适配器HandlerAdapter和映射器 ...

  6. polya定理,环形涂色

    环形涂色裸题 #include<iostream> #include<cstdio> #include<algorithm> #include<vector& ...

  7. Python 生成随机数函数和加密函数(MD5)

    内容来自debugtalk import hashlib import random import string def gen_random_string(str_len): '''生成指定长度的随 ...

  8. 以下示例使用一个 x,y 坐标列表创建了一个多边形几何对象。然后使用裁剪工具来裁剪具有多边形几何对象的要素类。

    import arcpy # Create an Array object. # array = arcpy.Array() # List of coordinates. # coordList = ...

  9. ubuntu如何删除刚添加的源?

    答: sudo add-apt-repository -r <source_url> 如: sudo add-apt-repository -r ppa:linaro-maintainer ...

  10. backbone之module

    上一篇列出了collection的代码,下面要把代码进行分离 //先是app.js var ContactManager = new Marionette.Application(); Contact ...