解题思路:我得思路都在代码注释中
参考代码:
m = int(input()) # 将输入的字符串存入列表 allstr = [] i = 0 while i < m: allstr.append(input()) i += 1 # 建立特殊字符数组 testr = "~!@#$%^" for s in allstr: lenth = len(s) if lenth < 8 or lenth > 16: print("NO") continue flag = 0 # 判断密码中是否含有大小写、数字、特殊字符 a = b = c = d = 0 for s1 in s: if s1 >= 'A' and s1 <= 'Z': a = 1 if s1 >= 'a' and s1 <= 'z': b = 1 if s1 >= '0' and s1 <= '9': c = 1 if s1 in testr: d = 1 # 只要密码中至少包含3种不同的字符种类,就结束当前字符串判断,继续判断下一个字符串 if a + b + c + d >= 3: flag = 1 print("YES") break if flag == 0: print("NO")
0.0分
0 人评分
C二级辅导-求偶数和 (C语言代码)浏览:606 |
简单的a+b (C语言代码)浏览:722 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:608 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:560 |
C二级辅导-公约公倍 (C语言代码)浏览:2122 |
C二级辅导-统计字符 (C语言代码)浏览:505 |
C语言训练-大、小写问题 (C语言代码)浏览:2352 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:541 |
字符串对比 (C语言代码)浏览:1413 |
Pascal三角 (C语言代码)浏览:1188 |