题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String mmzfc = fzhinput.nextLine(); boolean dzm = false, xzm = false, tszf = false; int sum=0,fh=0,sznum=0; for (int i = 0; i < mmzfc.length(); i++) { char ch = mmzfc.charAt(i); if (ch >= 'A' && ch <= 'Z') { dzm = true; } else if (ch >= 'a' && ch <= 'z') { xzm = true; } else if (ch >= '0' && ch <= '9') { sznum++; } else { fh++; } } if(dzm){ sum+=10; } if(xzm){ sum+=10; } if(sznum==0){ sum+=0; } else if(sznum==1){ sum+=10; } else if(sznum>1){ sum+=20; } if(fh==0){ sum+=0; } else if(fh==1){ sum+=10; } else if(fh>1){ sum+=25; } if(mmzfc.length()<=4){ sum+=5; } else if(mmzfc.length()<=7&&mmzfc.length()>=5){ sum+=10; } else if(mmzfc.length()>=8){ sum+=25; } if(dzm&&xzm&&sznum!=0&&fh!=0){ sum+=5; } else if((dzm||xzm)&&sznum!=0&&fh!=0){ sum+=3; } else if((dzm||xzm)&&sznum!=0&&fh==0){ sum+=2; } if(sum>=90){ System.out.println("VERY_SECURE"); } else if(sum>=80){ System.out.println("SECURE"); } else if(sum>=70){ System.out.println("VERY_STRONG"); } else if(sum>=60){ System.out.println("STRONG"); } else if(sum>=50){ System.out.println("AVERAGE"); } else if(sum>=25){ System.out.println("WEAK"); } else if(sum>=0){ System.out.println("VERY_WEAK"); } } }