网站做图分辨率是多少合适网站设计的思想
原题链接<----
islower 小写字母判断
 isupper 大写字母判断
 isdigit 数字判断
题目:
 小码哥在是一位密码领域的初学者,有一天他的老师给他了一串密码,要他判断这个密码是否是强密码,老师和他说强密码就是需要同时达到以下要求:
 1.密码长度大于6。
 2.密码中同时包括了大小写字母和数字。
 3.并且数字和数字之间不能相连。
样例1
 输入:
 They12wwweqwe
输出:
 False
样例 2
 输入:
 They1wwweqwe
输出:
 True
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
using namespace std;bool cmp(string x)
{return x.size()>6;
}bool cmp1(string x) //判断是否存在小写字母
{for(char it:x){if(islower(it)){return true;}}return false;	
}bool cmp2(string x) //是否存在大写字母
{for(char it:x){if(isupper(it)){return true;}}return false;	
}bool cmp3(string x) //判断是否存在数字
{for(char it:x){if(isdigit(it)){return true;}}return false;	
}bool cmp4(string x) //判断数字之间是否相连
{for(int i=0;i<x.size()-1;i++){if(isdigit(x[i]) && isdigit(x[i+1])){return false;}}	return true;
}int main()
{string str; getline(cin,str);if(cmp(str) && cmp1(str) && cmp2(str) && cmp3(str) &&cmp4(str)){printf("True\n");}else{printf("False\n");}return 0;
}
 
运行结果:
 
AI:
#include <iostream>  
#include <string>  
#include <cctype>  bool isLongEnough(const std::string& password) {  return password.length() > 6;  
}  bool hasLowerCase(const std::string& password) {  for (char c : password) {  if (std::islower(c)) {  return true;  }  }  return false;  
}  bool hasUpperCase(const std::string& password) {  for (char c : password) {  if (std::isupper(c)) {  return true;  }  }  return false;  
}  bool hasDigits(const std::string& password) {  for (char c : password) {  if (std::isdigit(c)) {  return true;  }  }  return false;  
}  bool hasConsecutiveDigits(const std::string& password) {  for (size_t i = 0; i < password.length() - 1; ++i) {  if (std::isdigit(password[i]) && std::isdigit(password[i + 1])) {  return true;  }  }  return false;  
}  bool isStrongPassword(const std::string& password) {  return isLongEnough(password) &&  hasLowerCase(password) &&  hasUpperCase(password) &&  hasDigits(password) &&  !hasConsecutiveDigits(password);  
}  int main() {  std::string password;  std::cout << "请输入密码: ";  std::cin >> password;  if (isStrongPassword(password)) {  std::cout << "这是一个强密码。" << std::endl;  } else {  std::cout << "这不是一个强密码。" << std::endl;  }  return 0;  
}
