坑点
题目中说的非空字符串,但是测试点2居然是空字符串,你敢信????
实现
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int N, i;
string standartd = "abcdefghijklmnopqrstuvtxyz0123456789.";
bool character, num,noExist;
string str;
cin >> N;
getchar();
while (N--)
{
character = false, num = false, noExist = false;
getline(cin,str); //测试点2
if (str.size()<6)
cout << "Your password is tai duan le." << endl;
else
{
for (i = 0; i<str.size(); i++)
{
if (isalpha(str[i]))
{
character = true; continue;
}
else if (isdigit(str[i]))
num = true;
else if (standartd.find(str[i]) == string::npos)
{
noExist = true; break;
}
}
if (noExist)
cout << "Your password is tai luan le." << endl;
else
{
if (num&&character)
cout << "Your password is wan mei." << endl;
else if (num && !character)
cout << "Your password needs zi mu." << endl;
else if (character && !num)
cout << "Your password needs shu zi." << endl;
}
}
}
return 0;
}
本文详细解析了一种用于检查密码强度的算法实现,通过判断密码是否包含字母、数字及特殊字符,确保密码长度不少于六位,以此来评估密码的安全性。文章通过C++代码示例,展示了如何使用标准库函数进行字符类型判断,并对测试点中出现的特殊情况进行了处理。
&spm=1001.2101.3001.5002&articleId=86663835&d=1&t=3&u=04d0cd52408a40a19ff72c47bba384d9)

被折叠的 条评论
为什么被折叠?



