域名已有服务器也有怎么做网站,用wordpress做的外贸网站,外发加工单表格范本,网页制作教程零基础合集描述 小明同学最近开发了一个网站#xff0c;在用户注册账户的时候#xff0c;需要设置账户的密码#xff0c;为了加强账户的安全性#xff0c;小明对密码强度有一定要求#xff1a; 1. 密码只能由大写字母#xff0c;小写字母#xff0c;数字构成#xff1b; 2. 密码不…描述 小明同学最近开发了一个网站在用户注册账户的时候需要设置账户的密码为了加强账户的安全性小明对密码强度有一定要求 1. 密码只能由大写字母小写字母数字构成 2. 密码不能以数字开头 3. 密码中至少出现大写字母小写字母和数字这三种字符类型中的两种 4. 密码长度至少为8 现在小明受到了n个密码他想请你写程序判断这些密码中哪些是合适的哪些是不合法的。
输入描述 输入一个数n接下来有n(n≤100)行每行一个字符串表示一个密码输入保证字符串中只出现大写字母小写字母和数字字符串长度不超过100。
输出描述 输入n行如果密码合法输出YES不合法输出NO。
示例 输入1 CdKfIfsiBgohWsydFYlMVRrGUpMALbmygeXdNpTmWkfyiZIKPtiflcgppuR 输出YES 分析先对密码第一个字符和密码长度进行判断若不合法直接判断下一个密码再对密码这个字符串进行遍历分别求各种字符的个数如果输入的字符不在字母大小写和数字范围内则不合法直接判断下一个密码最后判断小写字母、大写字母和数字三类中有几类。 C语言 #include stdio.h #includestring.h int main() { int n; scanf(%d,n); for(int i1;in;i) { char str[101]{0}; scanf(%s,str); if(strlen(str)8) { printf(NO\n); continue; } if(str[0]0str[0]9) { printf(NO\n); continue; } //分别记录小写字母、大写字母、数字和其他字符的个数 int character0,CHAR0,num0,other0; for(int j0;str[j]!\0;j) { if(str[j]astr[j]z) character; else if(str[j]Astr[j]Z) CHAR; else if(str[j]0str[j]9) num; else other; } if(other!0) { printf(NO\n); continue; } //三种字符出现少于两种 if((character0)(CHAR0)(num0)2) { printf(NO\n); continue; } printf(YES\n); } return 0; } Java import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in new Scanner(System.in); int nin.nextInt(); in.nextLine(); for(int i1;in;i) { String strin.nextLine(); char[] chstr.toCharArray(); if(ch.length8) { System.out.println(NO); continue; } if(ch[0]0ch[0]9) { System.out.println(NO); continue; } //分别记录小写字母、大写字母、数字和其他字符的个数 int character0,CHAR0,num0,other0; for(int j0;jch.length;j) { if(ch[j]ach[j]z) character; else if(ch[j]Ach[j]Z) CHAR; else if(ch[j]0ch[j]9) num; else other; } if(other!0) { System.out.println(NO); continue; } //字符类型个数 int count0; if(character0){ count; } if(CHAR0){ count; } if(num0){ count; } if(count2){ System.out.println(NO); continue; } System.out.println(YES); } } }