PAT 乙级 1081. 检查密码 (15) 【字符串】
题目链接
https://www.patest.cn/contests/pat-b-practise/1081
思路
有一个坑点 可能会输入空格 也就是说 要用 geline 或者 gets()
然后 对于
“………………….” 这种 一串小数点的数据 应该输出什么 我也不知道。。
应该是没有这种数据吧
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int legal(string s)
{
int len = s.size();
int a = 0, b = 0, c = 0;
for (int i = 0; i < len; i++)
{
if (s[i] >= '0' && s[i] <= '9' )
{
a = 2;
continue;
}
else if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
{
b = 3;
continue;
}
else if (s[i] == '.')
continue;
else
return 0;
}
return a + b;
}
int main()
{
int t;
cin >> t;
getchar();
while (t--)
{
string s;
getline(cin, s);
int len = s.size();
if (len < 6)
printf("Your password is tai duan le.\n");
else
{
int ans = legal(s);
if (ans == 0)
printf("Your password is tai luan le.\n");
else if (ans == 2)
printf("Your password needs zi mu.\n");
else if (ans == 3)
printf("Your password needs shu zi.\n");
else
printf("Your password is wan mei.\n");
}
}
}
PAT 乙级 1081. 检查密码 (15) 【字符串】的更多相关文章
- PAT Basic 1081 检查密码 (15 分)
本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母.数字和小数点 .,还必须既有字母也有数字. 输入格式: 输入第一行 ...
- PAT(B) 1081 检查密码(Java)
题目链接:1081 检查密码 (15 point(s)) 题目描述 本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母 ...
- 1081 检查密码 (15分)C语言
本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母.数字和小数点 .,还必须既有字母也有数字. 输入格式: 输入第一行 ...
- PAT 乙级 1076 Wifi密码 (15)
下面是微博上流传的一张照片:“各位亲爱的同学们,鉴于大家有时需要使用wifi,又怕耽误亲们的学习,现将wifi密码设置为下列数学题答案:A-1:B-2:C-3:D-4:请同学们自己作答,每两日一换.谢 ...
- PAT 1081 检查密码(15) (代码+思路)
1081 检查密码(15 分) 本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母.数字和小数点 .,还必须既有字母也 ...
- PAT 1081 检查密码
https://pintia.cn/problem-sets/994805260223102976/problems/994805261217153024 本题要求你帮助某网站的用户注册模块写一个密码 ...
- 【PAT】B1081 检查密码(15 分)
水题 #include<cstdio> #include<string.h> #include<ctype.h> #include<algorithm> ...
- PAT乙级 1031. 查验身份证(15) 标志要清零!!!!!!!!!
1031. 查验身份证(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 一个合法的身份证号码由17位地区. ...
- PAT 乙级 1067 试密码(20 分)
1067 试密码(20 分) 当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死.本题就请你实现这个小功能. 输入格式: 输入在第一行给出一个密码(长度 ...
随机推荐
- python selenium中调用js
python 中js中单引号和双引号混合编程 js = 'document.getElementsByName("m:ybzbxmbd:b_BIANHAO")[0].setAttr ...
- 安装 Groovy
brew install groovy http://wiki.jikexueyuan.com/project/groovy-introduction/install-groovy.html
- 将Solr的数据存到Hdfs上
具体官方文档 https://cwiki.apache.org/confluence/display/solr/Running+Solr+on+HDFS 修改solrconfig.xml文件 < ...
- ubuntu更改mysql的编码配置
1.Ctrl+t打开终端 2.输入mysql -u root -p 命令,进入MySQL 输入 SHOW VARIABLES LIKE 'char%'; 查看MySQL编码,有两个不是utf8 3.在 ...
- bat文件转换为exe文件
批处理文件转换为exe文件(简单的处理文件),点击下载 使用超简单的了,不多说.
- 高速掌握Lua 5.3 —— Lua与C之间的交互概览
Q:什么是Lua的虚拟栈? A:C与Lua之间通信关键内容在于一个虚拟的栈.差点儿全部的调用都是对栈上的值进行操作,全部C与Lua之间的数据交换也都通过这个栈来完毕.另外,你也能够使用栈来保存暂时变量 ...
- 如何在vs2010中添加Picture控件
1.新建项目,并在对话框控件中拖入picture控件,并做如下设置 2.在picture控件的属性栏需要进行如下修改:ID需要修改,不能为static ID是控件的唯一标识,PictureCtrl(p ...
- javascript---》Fcuntion对象
Function 对象的valueOf() 和 toString() 方法.返回函数的源代码,调试时有用 Function 对象的 length 属性返回函数期望的参数个数------>接受任意 ...
- Apache2.4 新virtualhost
创建配置文件 /etc/apache2/sites-available# sudo nano mysite.conf <VirtualHost *:> #ServerName hello. ...
- 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...