#include<iostream>
using namespace std;
int main()
{
int i,j,n,len,hasnum,hasword,hasother;
string str;
cin>>n;
char c=getchar();//接收第一个换行符
for(i=0;i<n;i++)
{
// cin>>str;
getline(cin,str);//字符串中可能有空格等
hasnum=0;//赋初值
hasword=0;
hasother=0;
if(str.length()<6)//如果密码过短,直接输出,进行下次循环
{
cout<<"Your password is tai duan le."<<endl;
continue;
}
for(j=0;j<str.length();j++)//遍历密码,查看数字,字母,非法字符的出现情况
{
if(str[j]>='a'&&str[j]<='z')hasword=1;
else if(str[j]>='A'&&str[j]<='Z')hasword=1;
else if(str[j]>='0'&&str[j]<='9')hasnum=1;
else if(str[j]=='.')
{
}
else hasother=1;
}
if(hasother)//有非法字符
{
cout<<"Your password is tai luan le."<<endl;
}
else
{
if(hasword&&hasnum)//合法密码
{
cout<<"Your password is wan mei."<<endl;
}
else if(hasword&&!hasnum)//无数字
{
cout<<"Your password needs shu zi."<<endl;
}
else if(!hasword&&hasnum)//无字母
{
cout<<"Your password needs zi mu."<<endl;
}
else//似乎并没有全是......的测试点
{
//cout<<"Your password needs shu zi.Your password needs zi mu."<<endl;
}
}
}
return 0;
}
pat乙1081 检查密码
最新推荐文章于 2020-12-01 14:43:03 发布