• 需要注意的就是把判定函数提取出来,这样可以简化代码,同时参数引用了&,可以对于传入参数进行修改。

    参考代码:
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cstdlib> struct node
{
char name[20], password[20];
bool ischange;//如果ischange==true表示password已经修改
}T[1005]; //函数用来判断t的password的是否需要修改,若需要则cnt加1
void crypt(node& t, int& cnt)
{
int len = strlen(t.password);
for (int i = 0; i < len; i++)
{
if (t.password[i] == '1')
{
t.password[i] = '@';
t.ischange = true;
}
else if (t.password[i] == '0')
{
t.password[i] = '%';
t.ischange = true;
}
else if (t.password[i] == 'l')
{
t.password[i] = 'L';
t.ischange = true;
}
else if (t.password[i] == 'O')
{
t.password[i] = 'o';
t.ischange = true;
}
} if (t.ischange)
{
cnt++;
}
} int main()
{
int n, cnt = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%s %s", T[i].name, T[i].password);
T[i].ischange = false;
} for (int i = 0; i < n; i++)
{
crypt(T[i], cnt);
}
if (cnt == 0)
{
if (n == 1)
{
printf("There is %d account and no account is modified", n);
}
else
{
printf("There are %d accounts and no account is modified", n);
}
}
else
{
printf("%d\n", cnt);
for (int i = 0; i < n; i++)
{
if (T[i].ischange == true)
{
printf("%s %s\n", T[i].name, T[i].password);
}
}
} system("pause");
return 0;
}

PATA1035Password的更多相关文章

随机推荐

  1. ubutun16.04 安装编译glog日志库

    glog 是一个 C++ 日志库,它提供 C++ 流式风格的 API.在安装 glog 之前需要先安装 gflags,这样 glog 就可以使用 gflags 去解析命令行参数(可以参见gflags ...

  2. nginx反向代理配置去除前缀

    (转载)原文链接:https://blog.csdn.net/gongchenyu/article/details/85960027 使用nginx做反向代理的时候,可以简单的直接把请求原封不动的转发 ...

  3. 【MySQL】Mariadb字符集

    Mariadb字符集 如果不设置字符集,可以查看mariadb的字符集的默认设置是latin1. 如下命令,查看Mariadb的默认配置: [root@oradb ~]# /usr/local/mys ...

  4. springboot 获取到的inputStream为空的问题

    springboot在接收http请求的时候读取的request的inputStream,造成我们想自己读取inputStream的时候发现inputStream已经无法读取了. 为了读取inputS ...

  5. ABA问题的产生及解决

    什么是ABA问题 在CAS算法中,需要取出内存中某时刻的数据(由用户完成),在下一时刻比较并交换(CPU保证原子操作),这个时间差会导致数据的变化. 1.线程1从内存位置V中取出A2.线程2从内存位置 ...

  6. Appium+python自动化(一)- 环境搭建—上(超详解)

    简介 今天是高考各地由于降水,特别糟糕,各位考生高考加油,全国人民端午节快乐.最近整理了一下自动化的东西,先前整理的python接口自动化已经接近尾声.即将要开启新的征程和篇章(Appium& ...

  7. Linux内核调优部分参数说明

    #接收套接字缓冲区大小的默认值(以字节为单位). net.core.rmem_default = 262144 #接收套接字缓冲区大小的最大值(以字节为单位). net.core.rmem_max = ...

  8. spring-session(一)揭秘续篇

    上一篇文章中介绍了Spring-Session的核心原理,Filter,Session,Repository等等,传送门:spring-session(一)揭秘. 这篇继上一篇的原理逐渐深入Sprin ...

  9. 反弹Shell原理及检测技术研究

    1. 反弹Shell的概念本质 所谓的反弹shell(reverse shell),就是控制端监听在某TCP/UDP端口,被控端发起请求到该端口,并将其命令行的输入输出转到控制端. 本文会先分别讨论: ...

  10. Ajax实现附件上传

    前两篇文章有介绍使用form.submit 实现附件的上传,但是这种方式使用起来很不方便,如过需要再上传成功以后执行一些其他的操作的时候比较麻烦.下面我为大家介绍下使用ajax实现附件上传的功能: 1 ...