Q - 密码(第二季水)
Description
首先,我们就要设置一个安全的密码。那什么样的密码才叫安全的呢?一般来说一个比较安全的密码至少应该满足下面两个条件:
(1).密码长度大于等于8,且不要超过16。 (2).密码中的字符应该来自下面“字符类别”中四组中的至少三组。
这四个字符类别分别为: 1.大写字母:A,B,C...Z; 2.小写字母:a,b,c...z; 3.数字:0,1,2...9; 4.特殊符号:~,!,@,#,$,%,^;
给你一个密码,你的任务就是判断它是不是一个安全的密码。
Input
Output
Sample Input
a1b2c3d4
Linle@ACM
^~^@^@!%
Sample Output
YES
NO
#include <iostream>
#include <string>
using namespace std;
bool f(string str,char a,char b)
{
bool flag=false;
int n=str.length();
for(int i=;i<n;i++){
if(str[i]>=a&&str[i]<=b){
flag=true;
break;
}
}
return flag;
}
bool g(string str)
{
bool flag=false;
int n=str.length();
for(int i=;i<n;i++){
if(str[i]==':'||str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^'){
flag=true;
break;
}
}
return flag;
}
int main()
{
int n,k=,p;
string str;
cin>>n;
while(k<n){
p=;
cin>>str;
int n=str.length();
if(n>=&&n<=){
if(f(str,'A','Z'))p++;
if(f(str,'a','z'))p++;
if(f(str,'',''))p++;
if(g(str))p++;
if(p>=)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
else cout<<"NO"<<endl;
k++;
}
//system("pause");
return ;
}
Q - 密码(第二季水)的更多相关文章
- D - Counterfeit Dollar(第二季水)
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- F - The Fun Number System(第二季水)
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...
- N - Robot Motion(第二季水)
Description A robot has been programmed to follow the instructions in its path. Instructions for the ...
- S - 骨牌铺方格(第二季水)
Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...
- R - 一只小蜜蜂...(第二季水)
Description 有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示. ...
- I - Long Distance Racing(第二季水)
Description Bessie is training for her next race by running on a path that includes hills so that sh ...
- V - 不容易系列之(4)――考新郎(第二季水)
Description 国庆期间,省城HZ刚刚举行了一场盛大的集体婚礼,为了使婚礼进行的丰富一些,司仪临时想出了有一个有意思的节目,叫做"考新郎",具体的操作是这 ...
- Y - Design T-Shirt(第二季水)
Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...
- B - Maya Calendar(第二季水)
Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...
随机推荐
- NSNotification消息
注册消息 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(方法) name:@"消息名字&q ...
- 仿QQ好友列表界面的实现
TableView有2种style:UITableViewStylePlain 和 UITableViewStyleGrouped. 但是QQ好友列表的tableView给人的感觉似乎是2个style ...
- POJ 1269 - Intersecting Lines 直线与直线相交
题意: 判断直线间位置关系: 相交,平行,重合 include <iostream> #include <cstdio> using namespace std; str ...
- Citrix 服务器虚拟化之十二 Xenserver灾难恢复
Citrix 服务器虚拟化之十二 Xenserver灾难恢复 (环境有限实验无法测试,配置步骤摘取自官方文档) XenServer 灾难恢复的工作原理在存储库(SR)上还原从主(生产)环境复制到备份环 ...
- JDBC学习入门
一.JDBC相关概念介绍 1.1.数据库驱动 这里的驱动的概念和平时听到的那种驱动的概念是一样的,比如平时购买的声卡,网卡直接插到计算机上面是不能用的,必须要安装相应的驱动程序之后才能够使用声卡和网卡 ...
- 关于 jQuery中 function( window, undefined ) 写法的原因
今天在读 jQuery 源码的时候,发现下面的写法: (function(window,undefined){ ...// code goes here })(window); window 作为参数 ...
- 【转】iOS代码规范
原文地址: http://www.cocoachina.com/ios/20150908/13335.html 简介: 本 文整理自Apple文档<Coding Guidelines for C ...
- 就是爱Java
就是爱Java,提供了Java代码示例,文章和教程,可以帮助你学习Java编程语言. 网站名称:就是爱Java 网站地址:http://java.openyu.org
- MSP430F149模拟IIC读写24C02程序
板子上设置了EEPROM存储器,型号为AT24C02.板子的硬件连接为:SCL--->P2.4,SDA--->P2.5.直接了当,贴上程序! ======================= ...
- 如何在WPF程序中使用ArcGIS Engine的控件
原文 http://www.gisall.com/html/47/122747-4038.html WPF(Windows Presentation Foundation)是美国微软公司推出.NET ...