您的位置:首页 > 其它

Coder-Strike 2014 - Qualification Round A. Password Check(简单字符串)

2014-04-15 16:24 423 查看
1、http://codeforces.com/contest/411/problem/A

2、题目:

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

3、AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char str[105];
int main()
{
while(scanf("%s",str)!=EOF)
{
int l=strlen(str);
if(l<5)
printf("Too weak\n");
else
{
int flag1=0,flag2=0,flag3=0,flag=0;
for(int i=0; i<l; i++)
{
if(str[i]>='a' && str[i]<='z')
{
flag1=1;
}
else if(str[i]>='A' && str[i]<='Z')
{
flag2=1;
}
else if(str[i]>='1' && str[i]<='9')
{
flag3=1;
}
else
{
continue;
}
if(flag1==1 && flag2==1 && flag3==1)
{
flag=1;
break;
}
}
if(flag==1)
printf("Correct\n");
else
printf("Too weak\n");
}

}
return 0;
}
/*
a
abacabaX12345CONTEST_is_STARTED!!11*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: