关键:char转ASCII码值来判断
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main()
{
int n;
string s;
scanf("%d",&n);
while(n>0)
{
cin>>s;
bool b1,b2,b3,b4;
b1 = b2 =b3 =b4 =false;
int len = s.length();
int result =0;
if(len>=8 && len<16)
{
while(len-1>=0)
{
int tmp = (int)s[len-1];
if(!b1)
{
if(tmp>=65 && tmp <=90)
{
b1 = true;
++result;
}
}
if(!b2)
{
if(tmp>=97 && tmp <=122)
{
b2 = true;
++result;
}
}
if(!b3)
{
if(tmp>=48 && tmp <=57)
{
b3 = true;
++result;
}
}
if(!b4)
{
if(tmp == 126 || tmp == 33|| tmp == 64 || (tmp>=35&&tmp<=37) || tmp == 94)
{
b4 = true;
++result;
}
}
--len;
}
if(result>=3)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
else
{
printf("NO\n");
}
--n;
}
return 0;
}