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

    参考代码:
#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. 彩虹表(rainbow table)

    前记 MD5的全称是Message-Digest Algorithm 5(信息-摘要算法): 特点是不可逆的,一般解密不了:那有没有想过,为什么各种工具网站都可以进行MD5解密呢?https://ww ...

  2. Window与Document

    Window 表示一个包含DOM文档的窗口,其 document 属性指向窗口中载入的 DOM文档.使用 document.defaultView 属性可以获取指定文档所在窗口.window作为全局变 ...

  3. golang---常用函数

    package main; import ( "os" "fmt" "time" "strings" ) //os包中的 ...

  4. MySql 参数赋值bug (MySql.Data, Version=6.9.6.0 沙雕玩意)

    直接将参数赋值为常量0则参数值为null,出现异常:MySql.Data.MySqlClient.MySqlException (0x80004005): Column 'PayType' canno ...

  5. 攻防世界 高手进阶区 web cat

    php cURL CURLOPT_SAFE_UPLOAD django DEBUG mode Django使用的是gbk编码,超过%F7的编码不在gbk中有意义 当 CURLOPT_SAFE_UPLO ...

  6. css flex兼容性

    我测试了一下css flex的兼容性 已经可以兼容到IE10了呀 为啥MDN上面的IE兼容性还是兼容到IE11 有点更新不及时的感觉

  7. CSSS选择器总结

    title: CSSS选择器总结 date: 2018-07-30 20:11:07 tags: css --- 在css的学习中有一个很容易让人混乱的就是css选择器,因为选择器有很多种,而且在使用 ...

  8. When does VideoToolbox' VTCompressionSession benefit from hardware acceleration?

    来源:http://stackoverflow.com/questions/19256897/when-does-videotoolbox-vtcompressionsession-benefit-f ...

  9. 有些CRM settype用事务码COMM_ATTRSET打不开的原因

    This question is asked by Dr. Lin. Issue For example, settype COM_COMMERCIAL could be opened via tco ...

  10. kubernetes学习控制器之StatefulSet控制器

    StatefulSet介绍 一.StatefulSet概述 StatefulSet是用来管理stateful(有状态)应用的StatefulSet管理Pod时,确保Pod有一个按序增长的ID与Depl ...