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 ...
随机推荐
- CSS 设计彻底研究(一)(X)HTML与CSS核心基础
第1章 (X)HTML与CSS核心基础 这一章重点介绍了4个方面的问题.先介绍了 HTML和XHTML的发展历程以及需要注意的问题,然后介绍了如何将CSS引入HTML,接着讲解了CSS的各种选择器,及 ...
- QT5.5实现串口通信
QT5.1以上版本自带QtSerialPort集成库,只要在头文件中集成 #include <QtSerialPort/QSerialPort> #include <QtSerial ...
- codeforces 342C Cupboard and Balloons(公式题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud C. Cupboard and Balloons A girl named Xen ...
- PHP设置http头信息
<?PHP function https($num) { $http = array ( 100 => "HTTP/1.1 100 Continue", 101 =&g ...
- 22. Generate Parentheses
https://leetcode.com/problems/generate-parentheses/ 题目大意:给出n对小括号,求出括号匹配的情况,用列表存储并返回,例如:n=3时,答案应为: [ ...
- c#一个分页控件的例子
一.首先下载一个dll,地址:http://pan.baidu.com/share/link?shareid=1628211605&uk=1342867987 二.添加到项目中 三.添加引用 ...
- sqlserver系统表操作
查询表名中包含‘user’的方法Select * From sysobjects Where name like '%user%' 如果知道列名,想查找包含有该列的表名,可加上系统表syscolumn ...
- C# Nullable可空类型
一个Nullable类型就是基本类型加上一个"是否为null指示器"的合成类型.对于一个类型,如果既可以给他分配一个值,也可以给它分配null引用,我们就说这个类型是可空的. 可空 ...
- LINQ to SQL和Entity Framework对比与关联 (转载)
LINQ to SQL和Entity Framework对比与关联 LINQ to SQL和Entity Framework都是一种包含LINQ功能的对象关系映射技术.他们之间的本质区别在 ...
- ServerProperties
Spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动.其内置Tomcat容器或Jetty容器,具体由配置来决定(默认Tomcat).当然你也可以将项 ...