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

    参考代码:
#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;
}

最新文章

  1. KOTLIN开发语言文档(官方文档) -- 2.基本概念
  2. Windows+Caffe+VS2013+python接口配置过程
  3. c模拟c++ const 转换
  4. ASP.NET MVC 路由(三)
  5. Button 设置适应不同版本 旋转以后大小相应的改变
  6. Backup: Date and Time in Perl6
  7. c++文件操作相关
  8. 实现一个div在浏览器水平居中
  9. [转载]date命令时间转换
  10. Spring+SpringMVC+MyBatis+easyUI整合进阶篇(二)RESTful API实战笔记(接口设计及Java后端实现)
  11. BZOJ_4197_[Noi2015]寿司晚宴_状态压缩动态规划
  12. CSS2属性选择器和css3选择器的用法和区别
  13. nexus-3.2.0-01.zip安装以及如何启动服务
  14. lfs(systemd版本)学习笔记-第4页
  15. [Hinton] Neural Networks for Machine Learning - Bayesian
  16. nodejs进程线程优化性能
  17. svn:Cannot negotiate authentication mechanism
  18. log4j的配置详解(转)
  19. Java 的 java_home, path, classpath
  20. 201552-53 《Java程序设计》第五周问题汇总

热门文章

  1. 轻量级搜索工具【Everything】的设置
  2. python--unittest测试框架
  3. java 中遍历Map的几种方法
  4. 前端学习:HTML的学习总结
  5. vue要求更新3.0-》使用axios的时候出现错误
  6. Mysql中分组函数
  7. vue中路由在新的标签页打开
  8. Golang中设置函数默认参数的优雅实现
  9. 基于YOLO3对图像加框的函数draw_image()
  10. redis的两种持久化方案