python大法好
import re
n=int(input())
for i in range(n):
ipt=input();
if len(ipt)<6:
print("Your password is tai duan le.")
else:
a=re.findall(r'[^A-Za-z0-9.]',ipt)
if a!=[]:
print("Your password is tai luan le.")
elif ipt.replace(".","").isdigit():
print("Your password needs zi mu.")
elif ipt.replace(".", "").isalpha():
print("Your password needs shu zi.")
else:
print("Your password is wan mei.")
c++实现
#include <iostream>
#include <string>
using namespace std;
int main(){
int N; cin>>N;
getchar();
string s;
for(int i=0;i<N;i++){
getline(cin,s);
for(int j=0;j<s.length() ;j++) s[j]=tolower(s[j]);
if(s.length() <6) cout<<"Your password is tai duan le."<<endl;
else{
int flag1=0,flag2=0,flag3=0;
for(int j=0;j<s.length() ;j++){
if(!((s[j]-'0'<=9&&s[j]-'0'>=0)||(s[j]-'a'<=25&&s[j]-'a'>=0)||s[j]-'.'==0)){
flag3=1;
break;
}
}
for(int j=0;j<s.length() ;j++){
if(s[j]-'0'<=9&&s[j]-'0'>=0){
flag1=1;
break;
}
}
for(int j=0;j<s.length() ;j++){
if(s[j]-'a'<=25&&s[j]-'a'>=0){
flag2=1;
break;
}
}
if(flag3==1) cout<<"Your password is tai luan le."<<endl;
else if(flag1==0) cout<<"Your password needs shu zi." <<endl;
else if(flag2==0) cout<<"Your password needs zi mu." <<endl;
else cout<<"Your password is wan mei." <<endl;
}
}
return 0;
}