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 ...
随机推荐
- mysql事件调度器
#查看mysql事件调度器是否开启 SHOW VARIABLES WHERE Variable_name = 'event_scheduler'; #开启mysql事件调度器功能 SET GLOBAL ...
- 在现代渲染API下,封装跨平台渲染框架的尝试 - 资源管理
小生资历浅薄,不讨论该主题的重要性与未来的意义,只是个人兴趣爱好平日对这个问题思考了很多,总觉得要写点东西记录下来.框架还没有定型,只是记录自己设计的过程. 系统要跨平台,首先得将平台相关的实现与平台 ...
- (转)在Eclipse中使用JUnit4进行单元测试
原地址:http://blog.csdn.net/andycpp/article/details/1327147
- 图的割点 桥 双连通(byvoid)
[点连通度与边连通度] 在一个无向连通图中,如果有一个顶点集合,删除这个顶点集合,以及这个集合中所有顶点相关联的边以后,原图变成多个连通块,就称这个点集为割点集合.一个图的点连通度的定义为,最小割点集 ...
- 加载php_curl.dll和php_openssl.dll出错原因及解决办法
今天在XP下安装PHP开发环境时,需要加载php_curl.dll这个动态库,自己想当然的在php.ini里把extension=php_curl.dll打开以为就可以了.可以在apache的logs ...
- Unity3d Web Player 的server端联网配置
新游戏出了第一个能跑完流程的版本,不得不佩服Unity3D强大的功力,PC.MAC OS.Linux.IOS.Android.web player,前天刚发布的unity3d 4.2版本还支持WIND ...
- 用H5实现微信的四个界面
代码更新中
- WPF笔记(2.4 Grid)——Layout
原文:WPF笔记(2.4 Grid)--Layout 第一章已经简单介绍过这个容器,这一节详细介绍.Grid一般是用表格(Grid.Row 和Grid.Column )的,比StackPanel更细致 ...
- 在wpf中如何让MediaElement的视频循环播放
原文:在wpf中如何让MediaElement的视频循环播放 MediaElement原始的播放是只播放一遍:如何设置让MediaElement播放 的视频或者音频循环播放,解决如下: 修改Media ...
- 在 ASP.NET MVC 项目中使用 WebForm、 HTML
原文地址:http://www.cnblogs.com/snowdream/archive/2009/04/17/winforms-in-mvc.html ASP.NET MVC和WebForm各有各 ...