HDOJ – 2043 密码

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2043

最基础的模拟题目,只要按照题目给出的要求进行判断即可。

代码如下:

#include<iostream>
#include<string>
using namespace std;
const string s="~!@#$%^";
string ss;
int n;
int yes(string a){
	if (a.size()<8 || a.size()>16) return 0;
	int t1,t2,t3,t4;
	t1=t2=t3=t4=0;
	for (string::size_type i(0);i<a.size();i++){
		if (a[i]>='A'&&a[i]<='Z'){
			t1=1;
			break;
		}
	}
	for (string::size_type i(0);i<a.size();i++){
		if ((a[i]>='a')&&(a[i]<='z')){
			t2=1;
			break;
		}
	}
	for (string::size_type i(0);i<a.size();i++){
		if (a[i]>='0'&&a[i]<='9'){
			t3=1;
			break;
		}
	}
	for (string::size_type i(0);i<a.size();i++){
		if (s.find(a[i],0)!=string::npos){
			t4=1;
			break;
		}
	}
	if (t1+t2+t3+t4>2) return 1;
	return 0;
}
int main(){
	
	scanf("%d\n",&n);
	while (n--){
		getline(cin,ss);
		if (yes(ss)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

我的博客
全部评论

相关推荐

下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务