EHDU-1039 asier Done Than Said?
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. 思路:
#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?的更多相关文章
- 【hihoCoder】1039 : 字符消除
题目:http://hihocoder.com/problemset/problem/1039 给定一个字符串s,只包含'A', 'B', 'C'三种字符 1. 向 s 的任意位置 (包括头和尾) 中 ...
- hihoCoder 1039字符消除 (字符串处理)
http://hihocoder.com/problemset/problem/1039 因为字符串只由3种字母组成,并且插入的字符也只能是这三种字符的其中一个,那么可以考虑枚举这三个字符其中一个字符 ...
- 1039. Course List for Student (25)
题目链接:http://www.patest.cn/contests/pat-a-practise/1039 题目: 1039. Course List for Student (25) 时间限制 2 ...
- PAT-乙级-1039. 到底买不买(20)
1039. 到底买不买(20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小红想买些珠子做一串自己喜欢的珠串 ...
- poj 1039 Pipe(叉乘。。。)
题目:http://poj.org/problem?id=1039 题意:有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从 ...
- 【宽搜】XMU 1039 Treausure
题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1039 题目大意: 给定n,m(1<=n,m<=1000),一张n*m的地图 ...
- 【hihocoder 1039 字符串消除】模拟
题目链接:http://hihocoder.com/problemset/problem/1039 题意:给定一个只由{A, B, C}组成的字符串s,长度为n, 故包含n+1个空隙:现要求在某个空隙 ...
- 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 ...
- HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)
并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...
- 【hihoCoder】#1039 : 字符消除 by C solution
#1039 : 字符消除 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi最近在玩一个字符消除游戏.给定一个只包含大写字母"ABC"的字符串s,消 ...
随机推荐
- Python3 与 C# 并发编程之~ 协程篇
3.协程篇¶ 去年微信公众号就陆陆续续发布了,我一直以为博客也汇总同步了,这几天有朋友说一直没找到,遂发现,的确是漏了,所以补上一篇 在线预览:https://github.lesschina.c ...
- 2018年秋季学期《c语言程序设计》学习总结
<c语言程序设计>第四周学习总结 <c语言程序设计>第五周学习总结 <c语言程序设计>第六周学习总结 <c语言程序设计>第七周学习总结 <c语言程 ...
- 爬虫保存cookies时重要的两个参数(ignore_discard和ignore_expires)的作用
两个参数的作用: 官方的解释: ignore_discard: save even cookies set to be discarded. ignore_expires: save even coo ...
- Matlab中hold on与hold off的用法
摘录自:https://blog.csdn.net/smf0504/article/details/51830963 https://www.cnblogs.com/shuqingstudy/p/48 ...
- npm install 之前做的事
在一个项目目录中,npm install之前,需要npm init,npm init会问你几个问题,有的需要输入,不想输入的一路回车就行,之后会自动创建一个package.json文件,有了这个pac ...
- 无连接运输的UDP、可靠数据传输原理、面向连接运输的TCP
由[RFC 768]定义的UDP只是做了运输协议能够做的最少工作.除了复用/分解功能极少量的差错检测外,它几乎没有对IP增加别的东西.如果应用程序开发人员选择UDP而不是TCP,则该应用程序差不多就是 ...
- jQuery使用(十):jQuery实例方法之位置、坐标、图形(BOM)
offset() position() scrollTop().scrollLeft width().height() innerWidth().outerWidth().innerHeight(). ...
- Spark Java API 之 CountVectorizer
Spark Java API 之 CountVectorizer 由于在Spark中文本处理与分析的一些机器学习算法的输入并不是文本数据,而是数值型向量.因此,需要进行转换.而将文本数据转换成数值型的 ...
- [物理学与PDEs]第1章第1节 引言
1. 电动力学研究的对象是电磁场, 研究电磁场的基本属性---运动规律及它和带电物质的相互作用. 2. 场, 物质的一种存在方式. 3. Maxwell 方程组是电动力学中的基本方程, 是一切有关电磁 ...
- Maven安装及配置
第1部分 准备 1.1 安装JDK和Eclipse: 1.2 下载Maven(https://maven.apache.org/download.cgi) 第2部分 2.1 安装Maven 2.1.1 ...