合法标准:
- 字符数大于等于8
- 至少含有下列字符类型中的三种:(1)A…Z (2)a…z (3)0…9 (4)~!@#$%^&*()-=
输入:若干字符数不大于50的仅含上述字符的字符串,以单独的"END"结束
/*Usage: Check the letter`s type of a string*/
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#define ch *(str+i)
bool ChkType(char* str);
int main(void){
char S[51];
for(scanf("%s", S); S[0]!='E' || S[1]!='N' || S[2]!='D' || S[3] != '\0'; scanf("%s", S))
printf(ChkType(S)?"YES\n":"NO\n");
return 0;
}
bool ChkType(char* str){
bool A[4]={0};
int i;
if(strlen(str)>=8)
for(i=0; i<strlen(str); i++)
{
if(ch <= 'Z' && ch >= 'A')
A[0] = 1;
else if(ch <= 'z' && ch >= 'a')
A[1] = 1;
else if(ch <= '9' && ch >= '0')
A[2] = 1;
else
A[3] = 1;
if(A[0]+A[1]+A[2]+A[3] == 3)
return 1;
}
return 0;
}