# 1081 check password (15 points)

Posted by PHPnewby! on Fri, 31 Jan 2020 11:42:12 +0100

1081 check password (15 points)

This question asks you to help the user registration module of a website write a small function of password validity check. The website requires that the password set by the user must be composed of no less than 6 characters, and can only have English letters, numbers and decimal points, as well as both letters and numbers.

### Input format:

Enter the first line to give a positive integer N (≤ 100), then N lines, each line to give a password set by the user, which is a non empty string of no more than 80 characters, ending with carriage return.

### Output format:

For each user's password, the system feedback information is output in one line, which is divided into the following five types:

• If the password is legal, output Your password is wan mei;
• If the password is too short, whether it is legal or not, output Your password is tai duan le;
• If the password length is legal, but there are illegal characters, then output Your password is tai luan le;
• If the password length is legal, but only letters do not have numbers, then output Your password needs shu zi;
• If the password length is legal, but only numbers have no letters, then output Your password needs zi mu.

```5
123s
zheshi.wodepw
1234.5678
WanMei23333
pass*word.6
```

### Output example:

```Your password is tai duan le.
```

Solution idea: it's not difficult. Judge the above four situations strictly according to the requirements of the question (Note: there may be spaces in the input password).

The code is as follows:

```#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
int i,n;
scanf("%d",&n);
getchar();
for(i=0;i<n;i++)
{
int m,j,k=0,t=0,y=1;
getline(cin,a);         //Space can be entered
m=a.size();
if(m<6)       //The password is too short.
{
continue;
}
else
{
for(j=0;j<m;j++)
{
if((a[j]>='A'&&a[j]<='Z')||(a[j]>='a'&&a[j]<='z')||(a[j]>='0'&&a[j]<='9')||(a[j]=='.'))  //Ensure effective
{
if(((a[j]>='A'&&a[j]<='Z')||(a[j]>='a'&&a[j]<='z'))&&(a[j]<'0'||a[j]>'9'))  //Only letters
{
k=1;
}
else if(a[j]>='0'&&a[j]<='9')    //Only numbers
{
t=1;
}
}
{
y=0;
break;
}
}
if(k==1&&t==1&&y==1)   //Legal situation
{
}
else if(k==1&&t==0&&y==1)   //Missing figures
{
}
else if(t==1&&k==0&&y==1)   //Missing letters
{