Easier Done Than Said?

                                                                    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)


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.
 
题意:给你一段密码,判断这段密码是否安全,若安全则是 acceptable。
密码必须同时满足下面三个限制条件才是安全密码:1、必须包含元音字母;
2、不能包含连续的三个元音或辅音字母;
3、除了ee和oo外,任何两个连续字母如果相同,密码就不安全。
#include<stdio.h>
#include<string.h>
int main()
{
int i,flag,len,vowel;
char str[25];
while(gets(str))
{
if(!strcmp(str,"end")) break;
len=strlen(str);
vowel=0; flag=1;
for(i=0;i<=1;i++) /*特判str[0]和str[1]*/
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
vowel++;
if(str[0]==str[1]&&str[0]!='o'&&str[0]!='e')
{
flag=0;
printf("<%s> is not acceptable.\n",str);
continue;
}
for(i=2;i<len;i++)
{
if((str[i]==str[i-1])&&(str[i]!='e'&&str[i]!='o')) /*两个连续*/
{
flag=0;
break;
}
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u') /*元音字母*/
vowel++;
if((str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')&&
(str[i-1]=='a'||str[i-1]=='e'||str[i-1]=='i'||str[i-1]=='o'||str[i-1]=='u')&&
(str[i-2]=='a'||str[i-2]=='e'||str[i-2]=='i'||str[i-2]=='o'||str[i-2]=='u')) /*三个连续元音*/
{
flag=0;
break;
}
if((str[i]!='a'&&str[i]!='e'&&str[i]!='i'&&str[i]!='o'&&str[i]!='u')&&
(str[i-1]!='a'&&str[i-1]!='e'&&str[i-1]!='i'&&str[i-1]!='o'&&str[i-1]!='u')&&
(str[i-2]!='a'&&str[i-2]!='e'&&str[i-2]!='i'&&str[i-2]!='o'&&str[i-2]!='u')) /*三个连续辅音*/
{
flag=0;
break;
}
}
if(flag&&vowel>0)
printf("<%s> is acceptable.\n",str);
else
printf("<%s> is not acceptable.\n",str);
}
return 0;
}

hdu 1039 Easier Done Than Said? 字符串的更多相关文章

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

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

  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. 题解报告: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 1039

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

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

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

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

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

  9. HDU 2087 剪花布条 (字符串哈希)

    http://acm.hdu.edu.cn/showproblem.php?pid=2087 Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图 ...

随机推荐

  1. How Does #DeepDream Work?

    How Does #DeepDream Work? Do neural networks hallucinate of electronic dogs? If you’ve been browsing ...

  2. WebKit Web Inspector增加覆盖率分析和类型推断功能

    WebKit中的Web Inspector(Web检查器)主要用于查看页面源代码.实时DOM层次结构.脚本调试.数据收集等,日前增加了两个十分有用的新功能:覆盖率分析和类型推断.覆盖率分析工具能够可视 ...

  3. PHP glob() 函数

    定义和用法 glob() 函数返回匹配指定模式的文件名或目录. 该函数返回一个包含有匹配文件 / 目录的数组.如果出错返回 false. 语法 glob(pattern,flags) 参数 描述 fi ...

  4. [状压dp]经典TSP

    0出发 每个顶点经过一次 回到0 最小花费. O($n^2 \times 2^n$) 记忆化搜索: // s: 已经访问过的节点状态 v: 出发位置 int dfs(int s, int v) { ) ...

  5. easyui源码翻译1.32--Tree(树)

    前言 使用$.fn.tree.defaults重写默认值对象.下载该插件翻译源码 树控件在web页面中一个将分层数据以树形结构进行显示.它提供用户展开.折叠.拖拽.编辑和异步加载等功能. 源码 /** ...

  6. 自定义NavigationView's item 的高度

    http://stackoverflow.com/questions/31204320/how-can-i-change-the-navigationviews-item-text-size 自定义s ...

  7. cto

    CTO(首席技术官)英文Chief Technology Officer,即企业内负责技术的最高负责人.这个名称在1980年代从美国开始时兴.起于做很多研究的大公司,如General Electric ...

  8. HAL打开驱动失败

    --- ---

  9. 【HDOJ】3275 Light

    这就是个简单线段树+延迟标记.因为对bool使用了~而不是!,wa了一下午找不到原因. /* 3275 */ #include <iostream> #include <sstrea ...

  10. Nagios ’status.cgi‘文件权限许可和访问控制漏洞

    漏洞名称: Nagios ’status.cgi‘文件权限许可和访问控制漏洞 CNNVD编号: CNNVD-201307-013 发布时间: 2014-02-21 更新时间: 2014-02-21 危 ...