给你一个字符串(包含大小写字母和数字),想知道这个字符串是否符合设定的密码要求,如果符合输出YES,不符合输出NO。定义规则如下:
1)长度必须不小于10
2)里面必须有大写字母和小写字母以及数字,但是第一个字符不能是数字
3)字母中不能含有Y
如果满足以上规则则认为这个密码符合要求
输入:每一组测试数据输入一个字符串
输出:对于每一组测试数据,输出对应答案
样例输入:
Abcda11111
样例输出:
YES
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
while(cin>>s)
{
string numbers("0123456789");
string upper("ABCDEFGHIJKLMNOPQRSTUVWXZ");
string lower("abcdefghijklmnopqrstuvwxyz");
int pos=s.find_first_of(numbers);
int Upos=s.find_first_of(upper);
int Lpos=s.find_first_of(lower);
int Y=s.find_first_of("Y");
//cout<<pos<<endl;
int len=s.size();
if(pos!=0 && pos!=-1 && len>=10 && Upos!=-1 && Lpos!=-1 && Y==-1)
{
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
}
return 0;
}