HDU 1039 Easier Done Than Said?
来源:互联网 发布:创新创业网络课答案 编辑:程序博客网 时间:2024/05/16 05:05
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.
题目大意:
输入为字符串,输入为end时表示结束。字符串满足
(1)它必须包含至少一个元音。
(2)它不能包含三个连续的元音或连续三个辅音。
(3)它不能包含两个连续出现相同的字母,除了’EE’或’OO’。
时输出<字符串> is acceptable.
不满足时则输出
<字符串> is not acceptable.
c++
#include <iostream>#include<cstring>#include<cstdio>#include<string>using namespace std;int bj(char a) //用于比较是元音还是辅音{ if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') return 1; else return 0;}int main(){ char a[100]; int b,c,d,e,f,g,m; while(cin>>a,strcmp(a,"end")!=0) { c=0;d=0;e=0; b=strlen(a); for(int i=0;i<b;i++) { if(bj(a[i])==1) //用于统计元音个数 c++; if(i+2<b) { f=bj(a[i]);g=bj(a[i+2]);m=bj(a[i+1]); if(f==g&&m==g&&m==f) //判断是否三个连续的元音或连续三个辅音。 d++; } if(a[i]==a[i+1]&&(a[i]!='e'&&a[i]!='o')) //判断是否包含两个连续出现相同的字母,除了'EE'或'OO'。 e++; } if(c>0&&d==0&&e==0) //判断是否满足题中所给条件 printf("<%s> is acceptable.\n",a); else printf("<%s> is not acceptable.\n",a); } return 0;}
- hdu 1039 Easier Done Than Said?
- HDU 1039 Easier Done Than Said?
- HDU 1039 - Easier Done Than Said?
- Hdu 1039 - Easier Done Than Said?
- hdu-1039Easier Done Than Said?
- HDU 1039 Easier Done Than Said? water~~~
- hdu 1039 Easier Done Than Said? 字符串
- Hdu---Easier Done Than Said---1039
- Easier Done Than Said? hdu 1039
- HDU--1039 -- Easier Done Than Said?
- HDU 1039 Easier Done Than Said?
- Easier Done Than Said?(hdu 1039)
- HDU 1039 Easier Done Than Said?
- hdu 1039 Easier Done Than Said?
- HDU 1039 Easier Done Than Said?
- hdu 1039 Easier Done Than Said?
- hdu 1039 Easier Done Than Said?
- HDU--1039:Easier Done Than Said? (字符串)
- 安卓内存泄露几种常见形式及解决方案
- dfs序(HDU 5296,Annoying problem)
- 未来的程序员还会有今天的收入吗?
- 最长回文子串 C++
- Android视图SurfaceView
- HDU 1039 Easier Done Than Said?
- Hibernate的autocommit问题
- response.setContentType与 request.setCharacterEncoding 区别
- Android存储系统之架构篇
- Golang 闭包的理解
- PC 处理器被边缘化,但在市场还占主导地位!
- SSH--Hibernate传值进数据库
- 中位数计数(暴力思维题)
- scanf 函数报错 error C4996: 'scanf'