Easier Done Than Said?

Problem Description
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them
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.
 
Input
The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.
 
Output
For each password, output whether or not it is acceptable, using the precise format shown in the example.
 
Sample Input
a
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end
 
Sample Output
<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】的更多相关文章

  1. hdu 1039 Easier Done Than Said? 字符串

    Easier Done Than Said?                                                                     Time Limi ...

  2. HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)

    Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy ...

  3. HDU 1039.Easier Done Than Said?-条件判断字符串

    Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...

  4. 题解报告:hdu 1039 Easier Done Than Said?

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 Problem Description Password security is a trick ...

  5. HDU 1039 -Easier Done Than Said?

    水水的 #include <iostream> #include <cstring> using namespace std; ]; bool flag; int vol,v2 ...

  6. HDU 1042.N!【高精度乘法】【8月24】

    N! Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N ...

  7. 字符串 HDU 1039

    规则: 1.必须至少包含一个元音字母.a e i o u 2.不能包含三个连续元音或者连续辅音字母. 3.不能包含两个连续字母,除了'ee'和'oo'. PS:字母个数(1<= N <=2 ...

  8. HDU 1039(字符串判断 **)

    题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件 ...

  9. hdu 5469 Antonidas(树的分治+字符串hashOR搜索+剪枝)

    题目链接:hdu 5469 Antonidas 题意: 给你一颗树,每个节点有一个字符,现在给你一个字符串S,问你是否能在树上找到两个节点u,v,使得u到v的最短路径构成的字符串恰好为S. 题解: 这 ...

随机推荐

  1. 【BZOJ 1211】 [HNOI2004]树的计数

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] prufer数列的应用 http://www.cnblogs.com/AWCXV/p/7626625.html 这一题没有节点的度数 ...

  2. 高级函数-sign

    ==========sign函数介绍(补充)===========   sign(n):判断n>0返回1;n=0返回0;n<0返回-1.   select sign(10),sign(0) ...

  3. Methods and systems for sharing common job information

    Apparatus and methods are provided for utilizing a plurality of processing units. A method comprises ...

  4. mysql的查询练习1

    1.多表查询

  5. WPF silverlight获取子控件(获取DataTemplate里的子控件)

    public static class VisualTreeExtensions { /// <summary> /// 获取父节点控件 /// </summary> /// ...

  6. sql中计算百分比

    sql中计算百分比:(转成字符串然后拼接%) ),) AS CHAR),'%') as aa from act_canal; 效果:

  7. 网页字体助手 WebFont Helper

    网页字体助手 是 Windows 平台离线的网页字体生成辅助工具.核心功能,采用 python 编写. WebFont Helper 功能特色 生成字体子集(即提取用到的字符生成字体,或者大家所说的字 ...

  8. 中文版 ImageNet Classification with Deep Convolutional Neural Networks

    ImageNet Classification with Deep Convolutional Neural Networks 摘要 我们训练了一个大型深度卷积神经网络来将ImageNet LSVRC ...

  9. Servlet学习(九)——request

    request运行流程在Servlet学习(四)——response已介绍,不再赘述 1.通过抓包工具获取Http请求 因为request代表请求,所以我们可以通过该对象分别获得Http请求的请求行, ...

  10. Java文件(io)编程——文件字节流的使用

    案例1: 演示FileInputStream类的使用(用FileInputStream的对象把文件读入到内存) 首先要在E盘新建一个文本文件,命名为test.txt,输入若干字符 public cla ...