当前位置: 代码迷 >> 综合 >> Coder-Strike 2014 - Qualification Round A. Password Check(简单字符串)
  详细解决方案

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

热度:4   发布时间:2024-01-13 20:14:58.0

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");elseprintf("Too weak\n");}}return 0;
}
/*
a
abacaba
X12345
CONTEST_is_STARTED!!11
*/


  相关解决方案