#include<iostream>
using namespace std;
int main() {
int n;
cin>>n;
getchar();
for(int i=0; i<n; i++) {
string pas;
getline(cin,pas);
if(pas.length()<6){ //长度不合法
cout<<"Your password is tai duan le."<<endl;
continue;
}
int ying=0,shu=0,dian=0,others=0;
for(int j=0;j<pas.length();j++) {
if(isalpha(pas[j])) ying++;
else if(isdigit(pas[j])) shu++;
else if(pas[j]=='.') dian++;
else others++;
}
if(others) cout<<"Your password is tai luan le."<<endl;
else if(ying>0&&shu==0) cout<<"Your password needs shu zi."<<endl;
else if(ying==0&&shu>0) cout<<"Your password needs zi mu."<<endl;
else cout<<"Your password is wan mei."<<endl;
}
return 0;
}
简单题,注意index i 和 j 不要弄混
这是一个简单的C++程序,用于检查输入的密码是否符合特定条件。程序读取用户输入的密码数量,然后逐个验证每个密码。如果密码长度小于6,则认为无效;如果包含字母但不包含数字,提示需要数字;如果包含数字但不包含字母,提示需要字母;否则,认为密码完美。
562

被折叠的 条评论
为什么被折叠?



