PJJ彭彭彭


私信TA

用户名:PJJ1997

访问量:56364

签 名:

试试单纯的暴力能暴到多少题

等  级
排  名 47
经  验 11391
参赛次数 10
文章发表 91
年  龄 20
在职情况 学生
学  校 广东药科大学
专  业 计算机科学与技术

  自我简介:

//用最笨的方法,把5种情况都列出来,比较好理解
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
int f1(string str)
{
	int i;
	for(i=0;i<str.size();i++)
	{
		if(str[i]>='0'&&str[i]<='9')
		{
			break;
		}
	}
	if(i!=str.size())
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int f2(string str)
{
	int i;
	for(i=0;i<str.size();i++)
	{
		if(str[i]>='a'&&str[i]<='z')
		{
			break;
		}
	}
	if(i!=str.size())
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int f3(string str)
{
	int i;
	for(i=0;i<str.size();i++)
	{
		if(str[i]>='A'&&str[i]<='Z')
		{
			break;
		}
	}
	if(i!=str.size())
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int f4(string str)
{
	int i;
	for(i=0;i<str.size();i++)
	{
		if(str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^')
		{
			break;
		}
	}
	if(i!=str.size())
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int main()
{
	int n;
	deque<string> q;
	string str[100001];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>str[i];
	}
	for(int i=0;i<n;i++)
	{
		if(f1(str[i])==0&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==1)
		{
			q.push_back("YES");
		}
		else if(f1(str[i])==1&&f2(str[i])==0&&f3(str[i])==1&&f4(str[i])==1)
		{
			q.push_back("YES");
		}
		else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==0&&f4(str[i])==1)
		{
			q.push_back("YES");
		}
		else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==0)
		{
			q.push_back("YES");
		}
		else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==1)
		{
			q.push_back("YES");
		}
		else
		{
			q.push_back("NO");
		}
	}
	copy(q.begin(),q.end(),ostream_iterator<string>(cout,"\n"));
	return 0;
}

解题思路:





注意事项:





参考代码:

 

0.0分

0 人评分

  评论区