题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039

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.

问题描述

密码安全性是一件棘手的事情。用户更喜欢易于记忆的简单密码(比如好友),但这样的密码通常不安全。有些网站使用随机计算机生成的密码(如xvtpzyo),但用户很难记住它们,有时会将它们写在粘在他们计算机上的记事上。一个可能的解决方案是生成相对安全但仍易于记忆的“可发音”密码。

FnordCom正在开发这样的密码生成器。您在质量控制部门工作,测试发生器并确保密码可接受是您的工作。为了让人接受,密码必须符合以下三条规则:

它必须至少包含一个元音。

它不能包含三个连续的元音或三个连续的辅音。

它不能包含两个连续出现的相同字母,除了'ee'或'oo'。

(就这个问题而言,元音是'a','e','i','o'和'u';所有其他字母都是辅音。)请注意,这些规则并不完美。有许多不可接受的常见/可发音词汇。

输入

输入由一个或多个潜在密码组成,每行一个,后面跟着一行只包含文字结束的单词'end'。每个密码至少有一个,最多只有二十个字母,并且只包含小写字母。

输出

对于每个密码,使用示例中显示的精确格式输出是否可接受。

解题思路:规则已经描述得很清楚了,主要是用f数组处理字符串中的字母,便于写if判断语句,然后就照着判断条件便可逐一写下来,写代码注意单一出口,简化代码。

AC代码:

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#define LL long long
#define PI acos(-1.0)
using namespace std;
char t[]={'a','e','i','o','u'};
bool isT(char a)//先扫一遍看看有没有元音字母,有的话直接返回真
{
for(int i=;i<;i++)
if(a==t[i])return true;
return false;
}
int main()
{
int len;//表示字符串的长度
char a[]={};
bool f[],g,h;//f数组是对字母进行标记
while(cin>>a,strcmp(a,"end")){
len=strlen(a);
memset(f,false,sizeof(f));//全部初始化为false
for(int i=;i<len;i++)//标记元音
if(isT(a[i]))f[i]=true;//是元音则为true
g=true,h=false;//g来判断条件,而h是用来标记至少有一个元音字母这个条件
for(int i=;i<len;i++){
if(f[i])h=true;//标记一下是否有元音字母
if(i>&&a[i]==a[i-]&&a[i]!='e'&&a[i]!='o'){g=false;break;}//标记连续相等的两个除了是e和o的
if(i>&&f[i]&&f[i-]&&f[i-]){g=false;break;}//标记连续三个是元音的
if(i>&&!f[i]&&!f[i-]&&!f[i-]){g=false;break;}//标记连续三个是辅音的
}
if(!h)g=false;//没有元音字母就置g为假,便于下一出口统一操作(单一出口)
if(g)cout<<'<'<<a<<'>'<<" is acceptable."<<endl;
else cout<<'<'<<a<<'>'<<" is not acceptable."<<endl;
}
return ;
}

题解报告:hdu 1039 Easier Done Than Said?的更多相关文章

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

    Easier Done Than Said?                                                                     Time Limi ...

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

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

  3. HDU 1039.Easier Done Than Said?【字符串处理】【8月24】

    Easier Done Than Said? Problem Description Password security is a tricky thing. Users prefer simple ...

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

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

  5. HDU 1039 -Easier Done Than Said?

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

  6. 题解报告:hdu 1398 Square Coins(母函数或dp)

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  7. 题解报告:hdu 2069 Coin Change(暴力orDP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...

  8. 题解报告:hdu 1028 Ignatius and the Princess III(母函数or计数DP)

    Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...

  9. 2015浙江财经大学ACM有奖周赛(一) 题解报告

    2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...

随机推荐

  1. Office EXCEL 中如何让一个单元格的数据链接到另一个工作表的数据

    比如我在Sheet2中定义了几个数据,这些都是简单的数字,而在Sheet1中让要被绑定的单元格等于Sheet2的对应单元格地址(比如Sheet2!B1,Sheet2!B2之类的)   然后就可以一改全 ...

  2. Win8系统如何在桌面行显示我的电脑

    1 桌面右击-个性化   2 更改桌面图标-然后可以在桌面上显示需要的东西

  3. ACdream原创群赛(13)のwuyiqi退役专场 C True love

    True love Time Limit: 4000/2000 MS (Java/Others)     Memory Limit:128000/64000 KB (Java/Others) Prob ...

  4. linux 【目录】

    [第一篇]linux[目录] [第五篇]特殊权限及定时任务 [第六篇]用户和用户管理及定时任务复习

  5. Android 封装实现各种样式对话框

    先上图 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/disso ...

  6. CSS的两个class选择器紧挨在一起

    有一段HTML代码: <a class="glyphicons white no-js cogwheel" href="#" target="_ ...

  7. 加载之ready和onload

    页面加载完成有两种事件,一是ready,表示文档结构已经加载完成(不包含图片等非文字媒体文件),二是onload,指示页面包含图片等文件在内的所有元素都加载完成. 真不知道这个标题该怎么取,暂时就先凑 ...

  8. 设计模式-(12)迭代器模式 (swift版)

    一,概念 迭代器模式(Iterator Pattern)是 Java 和 .Net 编程环境中非常常用的设计模式.这种模式用于顺序访问集合对象的元素,不需要知道集合对象的底层表示.迭代器模式属于行为型 ...

  9. UVALive3126 Taxi Cab Scheme —— 最小路径覆盖

    题目链接:https://vjudge.net/problem/UVALive-3126 题解: 最小路径覆盖:即在图中找出尽量少的路径,使得每个结点恰好只存在于一条路径上.其中单独一个点也可以是一条 ...

  10. bacth参数说明 cmd parameter

    http://www.robvanderwoude.com/parameters.php Windows NT 4 introduced a set of new features for comma ...