当前位置:网站首页>PAT B1081
PAT B1081
2022-06-25 19:55:00 【Madness makes freedom】
1081 Check the password (15 branch )
This topic requires you to help the user registration module of a website write a small function of password legitimacy check . The website requires that the password set by users must be no less than 6 Characters make up , And can only have English letters 、 Numbers and decimal points ., There must also be both letters and numbers .
Input format :
The first line of input gives a positive integer N(≤ 100), And then N That's ok , Each line gives a password set by the user , For no more than 80 A non empty string of characters , End with a carriage return .
Be careful : The title guarantees that there is no input with only decimal point .
Output format :
Password for each user , Output system feedback information in one line , Below 5 Kind of :
- If the password is legal , Output
Your password is wan mei.; - If the password is too short , Whether legal or not , All output
Your password is tai duan le.; - If the password length is legal , But there are illegal characters , The output
Your password is tai luan le.; - If the password length is legal , But only letters, no numbers , The output
Your password needs shu zi.; - If the password length is legal , But only numbers, no letters , The output
Your password needs zi mu..
sample input :
5
123s
zheshi.wodepw
1234.5678
WanMei23333
pass*word.6
sample output :
Your password is tai duan le.
Your password needs shu zi.
Your password needs zi mu.
Your password is wan mei.
Your password is tai luan le.It is worth noting that , If you use cin Function input , You should use getline Function input , Otherwise, a set of data cannot pass completely , Even if it's scanf Function cannot adopt , Use fgets() function , You can't use gets() function , as a result of gets Function in PAT Can't go through , also gets Functions also have drawbacks , When the input data is greater than gets Function's cache memory , It will overflow , Overwrite the contents of the cache . If use fgets function , If I make no mistakes , I think so :
char str[90];
fgets(stdin,90,str);
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
int n;
cin >> n;
getchar();
while(n--)
{
string str;
// cin >> str; // You can't use cin Input , Otherwise, a set of data will not pass , Because one line may have blank space input
getline(cin,str);
int len=str.size();
if(len<6)
{
cout << "Your password is tai duan le.\n";
continue;
}
int num=0,alpha=0;
for(int i=0;i<len;++i)
{
if(!isalnum(str[i])&&str[i]!='.')
{
cout << "Your password is tai luan le.\n";
break;
}
if(isdigit(str[i]))
num=1;
if(isalpha(str[i]))
alpha=1;
if(i==len-1&&num==0)
cout << "Your password needs shu zi.\n";
if(i==len-1&&alpha==0)
cout << "Your password needs zi mu.\n";
if(i==len-1&&num==1&&alpha==1)
cout << "Your password is wan mei.\n";
}
}
return 0;
}
边栏推荐
- 请问同花顺开户安全吗?
- Analyse du code source du processus d'acquisition et de connexion hikaricp II
- Jump jump games auxiliary (manual version) py code implementation
- ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
- Does GoogleSEO need to change the friend chain? (e6zzseo)
- Tcp/ip test questions (4)
- 在打新债开户证券安全吗?低佣金靠谱吗
- Browser performance optimization (19)
- Vscode debugging PHP configuration Xdebug
- Can GoogleSEO only do content without external chain? (e6zzseo)
猜你喜欢

Uncover ges super large scale graph computing engine hyg: Graph Segmentation

Wechat applet cloud function does not have dependency option installed

Guangzhou Sinovel interactive creates VR Exhibition Hall panoramic online virtual exhibition hall

Applet multi image to Base64 upload

Lilda Bluetooth air conditioning receiver helps create a more comfortable road life

Use of serialize() and serializearray() methods for form data serialization

Jsonp non homologous interaction (click trigger)

What should I pay attention to in GoogleSEO content station optimization?

Mqtt+ardunio+esp8266 development (excluding mqtt server deployment)

DARKHOLE 2
随机推荐
PostgreSQL change table owner
LNMP compilation and installation
Idea common plug-ins
Shell jump loop shift parameter left use of function
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
Tcp/ip test questions (4)
请问通达信开户安全吗?
Mqtt+ardunio+esp8266 development (excluding mqtt server deployment)
ActiveMQ--CVE-2016-3088
Using flex to implement the Holy Grail layout is as simple as that
Applet request interface encapsulation
Can GoogleSEO only do content without external chain? (e6zzseo)
Network security detection and prevention test questions (4)
Divine reversion EA
JQ implements tab switching
DARKHOLE 2
请问同花顺开户安全吗?
六、HikariConfig的配置解析
一、HikariCP获取连接流程源码分析一