PATA1035Password
2024-08-28 11:17:34
- 需要注意的就是把判定函数提取出来,这样可以简化代码,同时参数引用了&,可以对于传入参数进行修改。
参考代码:
#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;
}
最新文章
- KOTLIN开发语言文档(官方文档) -- 2.基本概念
- Windows+Caffe+VS2013+python接口配置过程
- c模拟c++ const 转换
- ASP.NET MVC 路由(三)
- Button 设置适应不同版本 旋转以后大小相应的改变
- Backup: Date and Time in Perl6
- c++文件操作相关
- 实现一个div在浏览器水平居中
- [转载]date命令时间转换
- Spring+SpringMVC+MyBatis+easyUI整合进阶篇(二)RESTful API实战笔记(接口设计及Java后端实现)
- BZOJ_4197_[Noi2015]寿司晚宴_状态压缩动态规划
- CSS2属性选择器和css3选择器的用法和区别
- nexus-3.2.0-01.zip安装以及如何启动服务
- lfs(systemd版本)学习笔记-第4页
- [Hinton] Neural Networks for Machine Learning - Bayesian
- nodejs进程线程优化性能
- svn:Cannot negotiate authentication mechanism
- log4j的配置详解(转)
- Java 的 java_home, path, classpath
- 201552-53 《Java程序设计》第五周问题汇总