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 ...
随机推荐
- Office 2010
1.Office Professional Plus 2010: 6QFDX-PYH2G-PPYFD-C7RJM-BBKQ8 BDD3G-XM7FB-BD2HM-YK63V-VQFDK 2.Offic ...
- java反射机制初探
最近和一位师兄交流了一下Java,真可谓是大有收获,让我好好的学习了一下javad的反射机制,同终于明白了spring等框架的一个基本实现的思想,那么今天就和大家分享一下java的反射机制. 反射,r ...
- 初学linux命令
linux系统的精髓在于它的命令行 早就听说要学习linux系统,就要学习它的命令行(Command Line Interface).说来惭愧,已经使用了linuxmint快两个月了,虽然能够使用一些 ...
- FloatingActionButton 完全解析[Design Support Library(2)]
一.简单使用 布局: <android.support.design.widget.FloatingActionButton android:layout_width="wrap_co ...
- makefile 单独编译一个文件
#!/sh/bin .SUFFIXES:.c.o CDIR = /Users/shelley/c BINDIR = $(CDIR)/bin CC = gcc CFLAGS = -g -O RM = r ...
- werkzeug源码阅读笔记(二) 上
因为第一部分是关于初始化的部分的,我就没有发布出来~ wsgi.py----第一部分 在分析这个模块之前, 需要了解一下WSGI, 大致了解了之后再继续~ get_current_url()函数 很明 ...
- Prime Path(POJ 3126 BFS)
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15325 Accepted: 8634 Descr ...
- ArcEngine10在VS2010中编译问题
原文 http://www.gisall.com/html/47/122747-4141.html 问题描述: 前段时间装了个VS2010,用ArcEngine10在VS2010中基于.Net Fra ...
- ## GridView 布局:item设置的高度和宽度不起作用、自动适配列数、添加Header和Footer ##
一.item设置的高度和宽度不起作用 转自:http://www.cnblogs.com/0616--ataozhijia/p/6031875.html [Android Pro] listView和 ...
- python刷取CSDN博文访问量之一
python刷取CSDN博文访问量之一 作者:vpoet 注:这个系列我只贴代码,代码不注释.有兴趣的自己读读就懂了,纯属娱乐,望管理员抬手 若有转载一定不要注明来源 #coding=utf-8 ...