题解
柳神题解:
非空字符串,每个字符串以回⻋车结束,但是字符串里⾯可能会有空格,所以不能直接用cin,要 用getline接收一行字符。在接收完n后要getchar()读取⼀下行符才能⽤用getline,否则换⾏符会被读进 getline中~
Code
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
getchar();
while (N--)
{
string s;
getline(cin, s);
int len = s.size();
if (len < 6)
{
cout << "Your password is tai duan le.\n";
continue;
}
int a, b, c;
a = b = c = 0;
for (auto &e : s)
{
if (!isalnum(e) && e != '.')
a = 1;
if (isalpha(e))
b = 1;
if (isdigit(e))
c = 1;
}
if (a)
{
cout << "Your password is tai luan le.";
}
else if (c == 0)
cout << "Your password needs shu zi.";
else if (b == 0)
cout << "Your password needs zi mu.";
else
cout << "Your password is wan mei.";
cout << endl;
}
return 0;
}