CodeForces 411A Password Check

本文介绍了一个简单的密码复杂度检查算法,用于验证用户输入的密码是否足够复杂。算法通过检查密码长度、包含大写字母、小写字母及数字等条件来评估密码的安全性。
A. Password Check
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement such an automatic check.

Web-developers of the company Q assume that a password is complex enough, if it meets all of the following conditions:

  • the password length is at least 5 characters;
  • the password contains at least one large English letter;
  • the password contains at least one small English letter;
  • the password contains at least one digit.

You are given a password. Please implement the automatic check of its complexity for company Q.

Input

The first line contains a non-empty sequence of characters (at most 100 characters). Each character is either a large English letter, or a small English letter, or a digit, or one of characters: "!", "?", ".", ",", "_".

Output

If the password is complex enough, print message "Correct" (without the quotes), otherwise print message "Too weak" (without the quotes).

Sample test(s)
Input
abacaba
Output
Too weak
Input
X12345
Output
Too weak
Input
CONTEST_is_STARTED!!11
Output
Correct
#include<ctype.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;


int main(){
    int a,b,c,len,flag,flag1,flag2,flag3;
    char str[110];
    while(cin>>str){
        flag=flag2=flag3=0;
        len=strlen(str);
        if(len>=5){
            for(int i=0;i<len;i++){
                if(isdigit(str[i])){       //判断是数字返回非0,不是返回0
                    flag=1;
                }
                else if(islower(str[i])){  //判断是小写字母返回非0,不是返回0
                    flag2=1;
                }
                else if(isupper(str[i])){  //判断是大写字母返回非0,不是返回0
                    flag3=1;
                }
            }
            if(flag&&flag2&&flag3){
                cout<<"Correct"<<endl;
            }
            else{
                cout<<"Too weak"<<endl;
            }
        }
        else{
            cout<<"Too weak"<<endl;
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值