当前位置:网站首页>检查密码
检查密码
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;
}边栏推荐
- The use of TestNG, the testing framework (II): the use of TestNG XML
- Some interview suggestions for Android programmers "suggestions collection"
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- Delete element (with transition animation)
- Quarkus学习四 - 项目开发到部署
- <口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持
- Codeforces Round #803 (Div. 2)(A~D)
- MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
- Methods of software testing
- 故事點 vs. 人天
猜你喜欢

博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”

Use of UIC in QT

Development and design of animation surrounding mall sales website based on php+mysql

Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'

Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people

Systemserver process

uniapp自动化测试学习

Fabric.js 缩放画布

Fabric.js 自由绘制圆形

BeanUtils -- shallow copy -- example / principle
随机推荐
QT new project_ MyNotepad++
什么是 eRDMA?丨科普漫画图解
P1908 逆序对
Daily learning 2
Custom events, global event bus, message subscription and publishing, $nexttick
Penetrate the remote connection database through the Intranet
Generally speaking, if the error of inconsistent tab and space occurs frequently
删除元素(带过渡动画)
Daily learning 3
Fabric. JS free draw circle
C语言高级用法--函数指针:回调函数;转换表
Teamtalk source code analysis win client
Fabric. JS upper dash, middle dash (strikethrough), underline
[Hongke technology sharing] how to test DNS server: DNS performance and response time test
Methods of software testing
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
YOLOv3&YOLOv5输出结果说明
In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028
Fabric.js 元素被选中时保持原有层级