HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
Easier Done Than Said?
and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember.
FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:
It must contain at least one vowel.
It cannot contain three consecutive vowels or three consecutive consonants.
It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.
(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.
a
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end
<a> is acceptable.
<tv> is not acceptable.
<ptoui> is not acceptable.
<bontres> is not acceptable.
<zoggax> is not acceptable.
<wiinq> is not acceptable.
<eep> is acceptable.
<houctuh> is acceptable.
1:有元音字母
2:不能三个连续元音或辅音
3:不能连续两个同样的字母,除非ee或oo
直接推断。代码例如以下:
#include<cstdio>
#include<cstring>
int yuanfu[27]={0};
bool yuan(char s[]){//推断有无元音字字母
for(int i=0;i<strlen(s);i++)
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
return true;
return false;
}
bool sanlian(char s[]){//推断有无三个连续的元音或辅音字母
if(strlen(s)<3) return true;
for(int i=0;i<strlen(s)-2;i++)
if(yuanfu[s[i]-'a']==yuanfu[s[i+1]-'a']&&yuanfu[s[i+1]-'a']==yuanfu[s[i+2]-'a'])
return false;
return true;
}
bool erlian(char s[]){//推断有无两个连续同样非ee或oo字母
if(strlen(s)<2) return true;
for(int i=0;i<strlen(s)-1;i++)
if(s[i]==s[i+1]&&!(s[i]=='e'||s[i]=='o'))
return false;
return true;
}
int main(){
char s[110];
yuanfu[0]=yuanfu[4]=yuanfu[8]=yuanfu[14]=yuanfu[20]=1;
while(scanf("%s",s)!=EOF&&strcmp(s,"end")){
if(!yuan(s)) printf("<%s> is not acceptable.\n",s);
else if(!sanlian(s)) printf("<%s> is not acceptable.\n",s);
else if(!erlian(s)) printf("<%s> is not acceptable.\n",s);
else printf("<%s> is acceptable.\n",s);
}
return 0;
}
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
HDU 1039.Easier Done Than Said?【字符串处理】【8月24】的更多相关文章
- hdu 1039 Easier Done Than Said? 字符串
Easier Done Than Said? Time Limi ...
- HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)
Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy ...
- HDU 1039.Easier Done Than Said?-条件判断字符串
Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- 题解报告:hdu 1039 Easier Done Than Said?
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 Problem Description Password security is a trick ...
- HDU 1039 -Easier Done Than Said?
水水的 #include <iostream> #include <cstring> using namespace std; ]; bool flag; int vol,v2 ...
- HDU 1042.N!【高精度乘法】【8月24】
N! Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N ...
- 字符串 HDU 1039
规则: 1.必须至少包含一个元音字母.a e i o u 2.不能包含三个连续元音或者连续辅音字母. 3.不能包含两个连续字母,除了'ee'和'oo'. PS:字母个数(1<= N <=2 ...
- HDU 1039(字符串判断 **)
题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件 ...
- hdu 5469 Antonidas(树的分治+字符串hashOR搜索+剪枝)
题目链接:hdu 5469 Antonidas 题意: 给你一颗树,每个节点有一个字符,现在给你一个字符串S,问你是否能在树上找到两个节点u,v,使得u到v的最短路径构成的字符串恰好为S. 题解: 这 ...
随机推荐
- maven 测试写入JRE参数
项目在测试时碰到一个问题,就是JVM加载参数的问题. web项目本身在注入配置信息的时候,读取的是本地的配置文件,但是配置文件的位置是卸载tomcat 里面配置的JAVA_OPTS里面的. 问题出现了 ...
- 2015 Multi-University Training Contest 6 hdu 5358 First One
First One Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- POJ——T2352 Stars
http://poj.org/problem?id=2352 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 46592 ...
- 洛谷 P1825 [USACO11OPEN]玉米田迷宫Corn Maze
P1825 [USACO11OPEN]玉米田迷宫Corn Maze 题目描述 This past fall, Farmer John took the cows to visit a corn maz ...
- stl里面stack的注意事项
1. pop是不返回元素的.因为不能返回引用,只能返回实例.而这个实例是在函数里面初始化的,所以必须在外面再赋值和初始化.而如果实例复制失败,会产生丢失. 2. 而top是可以返回引用的.实际上,返回 ...
- Excel数据导入___你hold住么(一)
近期小编跟着团队一起开发ITOO3.0高校云平台项目,当中的收获是不言而喻滴,在项目中有个导入功能:导入学生信息:导入班级信息:导入教学楼信息等,在不知多少次的尝试之下,成功实现功能. 框架分析 详解 ...
- lua简单类的实现
原文地址:http://blog.csdn.net/qqmcy/article/details/37725177 类实现: MyClass = class("MyClass") - ...
- 项目复习期总结3:CSS引入方式,凝视,命名规范,背景,行高,文本属性
文件夹: 1.CSS凝视的书写 怎么写?优点? 2.CSS引入方式 各种的优缺点 3.选择器的写法与选择器的优先级 4.CSS命名规范 5.背景,行高 6.文本(text与font开头)等全部属性 ...
- 获取xml字符串中的属性值
pagexml = @"<?xml version='1.0' encoding='utf-8'?> <DATAPACKET Version='2.0'> <M ...
- 忽略PyCharm4中特定的警告提示信息
有一种简单的方式忽略PyCharm4中的警告,光标放在下划线上,a. 等灯泡出现,点击灯泡或者b. 按下Alt和Enter键,选择'Ignore errors like this'. 或者,在设置里更 ...