解题思路:
注意事项:
参考代码:
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n=Integer.parseInt(scanner.nextLine()); while(n-->0) { String s=scanner.nextLine(); if(s.length()<8 || s.length()>16) {//长度不符合 System.out.println("NO"); }else { boolean flag=false;//该密码是否安全的标志 int count=0; //设立标志,使其判断大小写、数字、特殊字符等都只判断一次 boolean capitalLetter=true,lowerCaseLetter=true,digit=true,specialCharacter=true; for(int i=0;i<s.length();i++) { char c=s.charAt(i); if(c>='A' && c<='Z' && capitalLetter) { count++; capitalLetter=false; }else if(c>='a' && c<='z' && lowerCaseLetter) { count++; lowerCaseLetter=false; }else if(c>='0' && c<='9' && digit) { count++; digit=false; }else if((c=='~' || c=='!' || c=='@' || c=='#' || c=='$' || c=='%' || c=='^') && specialCharacter){ count++; specialCharacter=false; } if(count==3) { System.out.println("YES"); flag=true; break; } } if(!flag) { System.out.println("NO"); } } } } }
0.0分
0 人评分
printf基础练习2 (C++代码)(受教了,,%#o和%#x的用途)三人行,必有我师,,多看题解会有收获浏览:1876 |
点我有惊喜!你懂得!浏览:1238 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:476 |
简单的a+b (C语言代码)浏览:606 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1432 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:564 |
循环入门练习6 (C语言代码)浏览:970 |
GC的苦恼 (C语言代码)浏览:621 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:1220 |
快速排序算法1浏览:884 |