【PAT】1081. 检查密码 (15)【C语言实现】

本文介绍了一个简单的C语言程序,用于检测用户输入的密码是否达到特定的强度标准。程序检查密码长度是否足够,并验证其是否包含字母、数字及特殊字符等元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


简单逻辑题。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
	int n;
	int i;
	char s[85];
		scanf("%d",&n);
		getchar();
		for(i=0;i<n;i++){
		memset(s,0,sizeof(s));	
		gets(s);
		int len=strlen(s);		
		if(len<6){
			printf("Your password is tai duan le.\n"); 
			continue;
		}
		else{
			int j;
			int flag1=0,flag2=0,flag3=0,flag4=0;
			for(j=0;j<len;j++){	
				if(s[j]=='.'){
					flag1=1;
				}
				else if(s[j]>='A'&&s[j]<='Z'||s[j]>='a'&&s[j]<='z'){
					flag2=1;
				}
				else if(s[j]>='0'&&s[j]<='9')
					flag3=1;
				else 
					flag4=1;
			}
			if(flag4){
				printf("Your password is tai luan le.\n");	
				continue;
			}	
			else if(flag2&&!flag3&&!flag4){
				printf("Your password needs shu zi.\n");
				continue; 
			}						
			else if(!flag2&&flag3&&!flag4){
				printf("Your password needs zi mu.\n"); 
				continue;
			}				
			else if((flag2&&flag3&&!flag4)||(flag1&&flag2&&flag3&&!flag4)){
				printf("Your password is wan mei.\n");
				continue;
			}
		}	
		}
	
	return 0;	
} 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值