"OJ in class" To determine password strength

Source: Internet
Author: User

A question of determining the password strength:

Assume that the following four types of characters are allowed as passwords:
(1) Uppercase English letters, (2) Lowercase English letters, (3) Number 0-9, (4) Special Symbols @-_ # ~
The following provisions are made for password strength:
Best: Length >=16, and contains the above four characters, and each class has at least two different characters
Strong: Does not conform to best rules, but is >=10 in length and contains the above four types of characters
Medium: does not conform to best, strong, but the length >=8, and contains at least three types of characters
Weak: does not conform to best, strong, medium regulations.
Now give you a combination of passwords, please determine the password strength.
Input format: A line of string (length <100, end of line break), and guaranteed to be the above four characters.
Output format: A line of information, first output password length, and then the intensity level, the middle empty one grid.

Input Sample 1:[email protected]_-#
Output Example 1:16 best
Input Sample 2:12345678ABCDEFGHXYZ
Output Example 2:19 Medium
Input sample 3:[email protected]
Output Example 3:4 Weak

The key is that each class has at least two different characters in best, and you can define multiple arrays if you want to implement this function.

C Source code: #include "stdio.h"
int main ()
{
Char a[100],sz[100],zm[100],zm[100],fh[100];
int i,j,k,l,m,n,sum,zm0,zm0,sz0,fh0;
i=0;
k=l=m=n=0;
zm0=0;
zm0=0;
sz0=0;
fh0=0;
sum=0;
while ((A[i]=getchar ())! = ' \ n ')
{
i++;
}
for (j=0;j<i;j++)
{
if (a[j]>= ' a ' &&a[j]<= ' Z ')
{
ZM[K]=A[J];
k++;
}

else if (a[j]>= ' a ' &&a[j]<= ' Z ')
{
ZM[L]=A[J];
l++;
}
else if (a[j]>= ' 0 ' &&a[j]<= ' 9 ')
{
SZ[M]=A[J];
m++;
}
Else
{
FH[N]=A[J];
n++;
}
}
Sum=k+l+m+n;
while (k--)
{
zm0++;
if (Zm[k]==zm[k-1])
zm0--;
}
while (l--)
{
zm0++;
if (Zm[l]==zm[l-1])
zm0--;
}
while (m--)
{
sz0++;
if (Sz[m]==sz[m-1])
sz0--;
}
while (n--)
{
fh0++;
if (Fh[n]==fh[n-1])
fh0--;
}
if (sum>=16&&zm0>=2&&zm0>=2&&sz0>=2&&fh0>=2)
printf ("%d best\n", sum);
else if (sum>=10&&zm0>=1&&zm0>=1&&sz0>=1&&fh0>=1)
printf ("%d strong\n", sum);
else if (sum>=8&& (zm0>=1&&zm0>=1&&sz0>=1) | | | (zm0>=1&&zm0>=1&&fh0>=1) | | (zm0>=1&&sz0>=1&&fh0>=1)))
printf ("%d medium\n", sum);
Else
printf ("%d weak\n", sum);
return 0;
}

"OJ in class" To determine password strength

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.