当前位置:网站首页>检查密码
检查密码
2022-07-02 11:21:00 【名之以父】
一、题目描述
本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点 .
,还必须既有字母也有数字。
二、输入格式
输入第一行给出一个正整数 N(≤ 100),随后 N 行,每行给出一个用户设置的密码,为不超过 80 个字符的非空字符串,以回车结束。
注意: 题目保证不存在只有小数点的输入。
三、输出格式
对每个用户的密码,在一行中输出系统反馈信息,分以下5种:
- 如果密码合法,输出
Your password is wan mei.
; - 如果密码太短,不论合法与否,都输出
Your password is tai duan le.
; - 如果密码长度合法,但存在不合法字符,则输出
Your password is tai luan le.
; - 如果密码长度合法,但只有字母没有数字,则输出
Your password needs shu zi.
; - 如果密码长度合法,但只有数字没有字母,则输出
Your password needs zi mu.
。
四、输入样例
5
123s
zheshi.wodepw
1234.5678
WanMei23333
pass*word.6
输出样例
Your password is tai duan le.
Your password needs shu zi.
Your password needs zi mu.
Your password is wan mei.
Your password is tai luan le.
五、代码演示
#include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d", &n);//输出n
getchar();
char a[81];
int len;
while (n--)
{
int cha = 0, num = 0, point = 0, other = 0;
gets(a);
len = strlen(a);
if (len < 6) {
printf("Your password is tai duan le.\n");
continue;
}
else for (int i = 0; i < len; i++)
{
if (a[i] >= '0' && a[i] <= '9')num++;
else if (a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z')cha++;
else if (a[i] == '.')point++;
else other++;
}
if (other != 0)printf("Your password is tai luan le.\n");
else if (cha != 0 && num == 0)printf("Your password needs shu zi.\n");
else if (cha == 0 && num != 0)printf("Your password needs zi mu.\n");
else printf("Your password is wan mei.\n");
}
return 0;
}
边栏推荐
- Adhere to the foundation of 20 minutes go every day II
- 篇9:XShell免费版安装
- 没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
- 一般来讲,如果频繁出现inconsistent tab and space的报错
- [development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)
- Fabric. Keep the original level when JS element is selected
- The use of TestNG, the testing framework (II): the use of TestNG XML
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- [to be continued] [UE4 notes] l5ue4 model import
- <口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持
猜你喜欢
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
[development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)
c# 水晶报表打印
Mysql5.7 installation super easy tutorial
Whole house Wi Fi: a pain point that no one can solve?
C crystal report printing
万物生长大会在杭召开,当贝入选2022中国未来独角兽TOP100榜单
联合搜索:搜索中的所有需求
关于Flink框架窗口(window)函数最全解析
随机推荐
抓包工具fiddler学习
Mysql5.7 installation super easy tutorial
【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试
Daily learning 2
Fabric. JS zoom canvas
Pycharm连接远程服务器
给Android程序员的一些面试建议「建议收藏」
P1908 reverse sequence pair
自定义事件,全局事件总线,消息订阅与发布,$nextTick
NLA natural language analysis realizes zero threshold of data analysis
MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
Use of swagger
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
你知道Oracle的数据文件大小有上限么?
Go operation redis
Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
Adhere to the foundation of 20 minutes go every day II
Yolov3 & yolov5 output result description
Quarkus learning IV - project development to deployment