博客
关于我
L1-6 检查密码 (15分)
阅读量:342 次
发布时间:2019-03-04

本文共 1416 字,大约阅读时间需要 4 分钟。

L1-6 检查密码 (15分)

本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于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.

PS:不会真有人第三个点卡住吧

AC代码:
#include
#include
int main(){ int n; scanf("%d\n",&n); while(n--) { char a[100]; gets(a);//输入时有可能有空格,所以按行读入 if(strlen(a)<6) printf("Your password is tai duan le.\n"); else { int ch=0,num=0; for(int i=0;a[i];i++) { if(!((isdigit(a[i]))||isalpha(a[i])||a[i]=='.')) { printf("Your password is tai luan le.\n"); goto loop; } if(isdigit(a[i])) num=1; if(isalpha(a[i])) ch=1; } if(num&&!ch) printf("Your password needs zi mu.\n"); else if(ch&&!num) printf("Your password needs shu zi.\n"); else printf("Your password is wan mei.\n"); loop:; } }}

转载地址:http://vpwe.baihongyu.com/

你可能感兴趣的文章
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>