代码拉取完成,页面将自动刷新
#include<iostream>
#include<string>
using namespace std;
int score_sum(string& str)
{
int dig = 0, sym = 0;
int low = 0, up = 0, charc = 0;
int size = 0, sum = 0;
for (auto ch : str)
{
if (ch >= 'a' && ch <= 'z')
{
low++;
charc++;
}
else if (ch >= 'A' && ch <= 'Z')
{
up++;
charc++;
}
else if (ch >= '0' && ch <= '9')
{
dig++;
}
else if ((ch >= 0x21 && ch <= 0x2F)
|| (ch >= 0x3A && ch <= 0x40)
|| (ch >= 0x5B && ch <= 0x60)
|| (ch >= 0x7B && ch <= 0x7E))
{
sym++;
}
}
size = str.size();
if (size <= 4)
{
sum += 5;
}
else if (size <= 7)
{
sum += 10;
}
else
{
sum += 25;
}
if (low > 0 && up > 0)
{
sum += 20;
}
else if (low == charc || up == charc)
{
sum += 10;
}
if (dig == 1)
{
sum += 10;
}
else if (dig > 1)
{
sum += 20;
}
if (sym == 1)
{
sum += 10;
}
else if (sym > 1)
{
sum += 25;
}
if (low > 0 && up > 0 && dig > 0 && sym > 0)
{
sum += 5;
}
else if ((low > 0 || up > 0) && dig > 0 && sym > 0)
{
sum += 3;
}
else if ((low > 0 || up > 0) && dig > 0 && sym == 0)
{
sum += 2;
}
return sum;
}
int main()
{
string str;
while (cin >> str)
{
int score = score_sum(str);
if (score >= 90)
{
cout << "VERY_SECURE" << endl;
}
else if (score >= 80)
{
cout << "SECURE" << endl;
}
else if (score >= 70)
{
cout << "VERY_STRONG" << endl;
}
else if (score >= 60)
{
cout << "STRONG" << endl;
}
else if (score >= 50)
{
cout << "AVERAGE" << endl;
}
else if (score >= 25)
{
cout << "WEAK" << endl;
}
else if (score >= 0)
{
cout << "VERY_WEAK" << endl;
}
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。