360笔试9.11第二题代码,求第一题代码分享

第一题 实在没有思路,直接 cout << 3; 骗了18%
第二题逐个遍历,在输入上花的时间比较多一点,最后还是AC了,以下是我第二题的代码,求大佬分享一下第一题的代码
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	string s;
	vector<string> res;
	while (cin >> s) {
		res.push_back(s);
		if (cin.get() == '\0')
			break;
	}
	int len = res.size();
	for (int i = 0; i < len; i++) {
		int num = res[i].size();
		string tem = res[i];
		int flag = 0;
		int flag1 = 0;
		int flag2 = 0;
		int flag3 = 0;
		if (num >= 8) {
			for (int j = 0; j < num; j++) {
				if ((tem[j] >= 'a') && (tem[j] <= 'z') ){
					flag++;
					continue;
				}
				else if ((tem[j] >= 'A') && (tem[j] <= 'Z')) {
					flag1++;
					continue;
				}
				else if ((tem[j] >= '0') && (tem[j] <= '9')) {
					flag2++;
					continue;
				}
				else  {
					flag3++;
					continue;
				}
				if ((flag > 0 )&& (flag1 > 0 )&& (flag2 > 0 )&& (flag3 > 0)) {
					cout << "Ok" << '\n';
					break;
				}
			}
			if ((flag > 0 )&& (flag1 > 0) && (flag2 > 0 )&& ( flag3 > 0))
				cout << "Ok" << '\n';
			else
				cout << "Irregular password" << '\n';
		}
		else
			cout << "Irregular password" << '\n';
	}
	return 0;
}



#笔试题型##360公司#
全部评论
C++ isalpha(判断是否为特殊字符)、isalnum、islower、isupper
1 回复
分享
发布于 2020-09-11 22:18
第二题用正则做的,一直是55%不知道为啥
点赞 回复
分享
发布于 2020-09-11 22:08
联易融
校招火热招聘中
官网直投
同问第一题什么思路
点赞 回复
分享
发布于 2020-09-11 22:08
第一题骗了27
点赞 回复
分享
发布于 2020-09-11 22:17

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务