坑点
题目中说的非空字符串,但是测试点2居然是空字符串,你敢信????
实现
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int N, i;
string standartd = "abcdefghijklmnopqrstuvtxyz0123456789.";
bool character, num,noExist;
string str;
cin >> N;
getchar();
while (N--)
{
character = false, num = false, noExist = false;
getline(cin,str); //测试点2
if (str.size()<6)
cout << "Your password is tai duan le." << endl;
else
{
for (i = 0; i<str.size(); i++)
{
if (isalpha(str[i]))
{
character = true; continue;
}
else if (isdigit(str[i]))
num = true;
else if (standartd.find(str[i]) == string::npos)
{
noExist = true; break;
}
}
if (noExist)
cout << "Your password is tai luan le." << endl;
else
{
if (num&&character)
cout << "Your password is wan mei." << endl;
else if (num && !character)
cout << "Your password needs zi mu." << endl;
else if (character && !num)
cout << "Your password needs shu zi." << endl;
}
}
}
return 0;
}