想法
这道题对我来说没有那样简单,最开始就出现了段错误;
后看了一些大佬的程序,有了一些新的想法;
思路
(1)输入n,每个密码,循环输入,在循环内进行判断;
(2)循环内:如果密码小于六位数,即输出Your password is tai duan le.否则执行下条循环,计数字母、数字、小数点、或其他不合法字
符,在如题判断并输出;
代码
#include<stdio.h>
#include<string.h>
int main()
{int n;scanf("%d",&n);//输出ngetchar();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;
}
反思
应该写完程序立马写博客的,现在写总是不能写得特别全面;
写完一个程序,闭着眼睛听首曾轶可的歌,青春真美好呢,hh;
本文发布于:2024-02-05 04:40:30,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170724367863117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |