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.

InputThe 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. 
OutputFor 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个连续的元音或辅音;
(3)不能有连续相同的字母,除非是 ‘e' 或 'o';
#include<bits/stdc++.h>
using namespace std;
#define N 1000001
char s[N];
int main()
{
while(scanf("%s",s),strcmp(s,"end")){ //end 结束
int len=strlen(s),a=0,b=0; // a 表示连续的元音, b 表示连续的辅音
int x = 0,y = 0; //y 表示是否出现过元音,x 表示是否有不符合条件2、3的情况
for(int i=0;i<len;i++){
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' ||s[i]=='u'){
y = 1;
a++;
b=0;
}
else{
b++,a=0;
}
if(a==3 || b==3){
x = 1;
break;
}
if(i!=0 && s[i]!='e'&&s[i]!='o' && s[i]==s[i-1]){
x = 1;
break;
}
}
if(x || !y){
printf("<%s> is not acceptable.\n",s);
}
else{
printf("<%s> is acceptable.\n",s);
}
}
return 0;
}

  

EHDU-1039 asier Done Than Said?的更多相关文章

  1. 【hihoCoder】1039 : 字符消除

    题目:http://hihocoder.com/problemset/problem/1039 给定一个字符串s,只包含'A', 'B', 'C'三种字符 1. 向 s 的任意位置 (包括头和尾) 中 ...

  2. hihoCoder 1039字符消除 (字符串处理)

    http://hihocoder.com/problemset/problem/1039 因为字符串只由3种字母组成,并且插入的字符也只能是这三种字符的其中一个,那么可以考虑枚举这三个字符其中一个字符 ...

  3. 1039. Course List for Student (25)

    题目链接:http://www.patest.cn/contests/pat-a-practise/1039 题目: 1039. Course List for Student (25) 时间限制 2 ...

  4. PAT-乙级-1039. 到底买不买(20)

    1039. 到底买不买(20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小红想买些珠子做一串自己喜欢的珠串 ...

  5. poj 1039 Pipe(叉乘。。。)

    题目:http://poj.org/problem?id=1039 题意:有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从 ...

  6. 【宽搜】XMU 1039 Treausure

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1039 题目大意: 给定n,m(1<=n,m<=1000),一张n*m的地图 ...

  7. 【hihocoder 1039 字符串消除】模拟

    题目链接:http://hihocoder.com/problemset/problem/1039 题意:给定一个只由{A, B, C}组成的字符串s,长度为n, 故包含n+1个空隙:现要求在某个空隙 ...

  8. POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划)

    POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划) Descri ...

  9. HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)

    并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...

  10. 【hihoCoder】#1039 : 字符消除 by C solution

    #1039 : 字符消除 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi最近在玩一个字符消除游戏.给定一个只包含大写字母"ABC"的字符串s,消 ...

随机推荐

  1. 【JVM】Java内存模型

    原文:多线程之Java内存模型(JMM)(一) 概述 多任务和高并发是衡量一台计算机处理器的能力重要指标之一.一般衡量一个服务器性能的高低好坏,使用每秒事务处理数(Transactions Per S ...

  2. <Android基础> (五) 广播机制

    1)接收系统广播:a.动态注册监听网络变化 b.静态注册实现开机启动 2)发送自定义广播:a.发送标准广播 b.发送有序广播 3)使用本地广播 第五章 5.1 广播机制 Android中的每个程序都可 ...

  3. 【Java面试题】19 final,finally和finalize的区别

    总体区别 final       用于申明属性,方法和类,表示属性不可变,方法不可以被覆盖,类不可以被继承.finally     是异常处理语句结构中,表示总是执行的部分. finallize   ...

  4. Entity Framework入门教程(4)---EF中的实体关系

    这一节将总结EF是怎么管理实体之间的关系.EF与数据库一样支持三种关系类型:①一对一 ,②一对多,③多对多. 下边是一个SchoolDB数据库的实体数据模型,图中包含所有的实体和各个实体间的关系.通过 ...

  5. .net Core 下数据库访问

    SqlSugar :是一款高性能(达到ADO.NET最高性能水平)SqlSugar :是除EF外拉姆达解析最完善的ORM,多表 .UnionALL. 交叉子查询.真实的批量操作和分页SqlSugar ...

  6. 第十四节:再探MVC中路由的奥秘

    一. 基于RouteBase扩展 1. 原理 扩展RouteBase,同样使用的是MVC框架提供的MvcRouteHandler进行处理. 2. 步骤 1. 新建YpfRoute1类,继承RouteB ...

  7. javaScript事件机制深入学习(事件冒泡,事件捕获,事件绑定方式,移除事件方式,阻止浏览器默认行为,事件委托,模拟浏览器事件,自定义事件)

    前言 JavaScript与HTML之间的交互是通过事件实现的.事件,就是文档或浏览器窗口中发生的一些特定的交互瞬间.可以使用侦听器(或处理程序)来预订事件,以便事件发生时执行相应的代码.这种在传统软 ...

  8. DNS服务器 知识点

    DNS服务器: 1.DNS: Domain Name Service 域 名字 服务 2.域名组成:(树形结构) 根域 .顶级域 国家顶级域 cn jp hk uk 商业顶级域 com 商业机构 go ...

  9. 迅为iTOP-4418/6818开发板-驱动-实现GPIO扩展

    实现 GPIO 扩展,先弄清楚“复用”的概念,将调用这些 GPIO 的驱动去掉配置,重新编译,加到自己的驱动中,就可以实现扩展的 GPIO 的输入和输出.另外必须要先看文档“迅为iTOP-4418开发 ...

  10. Django跨域请求

    一.jsonp方式 同源策略会阻止ajaxa请求,但不阻止src. jsonp方式其实是利用了<script>标签可以直接跨域的性质,在body中生成一个<script>标签, ...