Easier Done Than Said?

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.

1:有元音字母

2:不能三个连续元音或辅音

3:不能连续两个同样的字母,除非ee或oo

直接推断。代码例如以下:

#include<cstdio>
#include<cstring>
int yuanfu[27]={0};
bool yuan(char s[]){//推断有无元音字字母
for(int i=0;i<strlen(s);i++)
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
return true;
return false;
}
bool sanlian(char s[]){//推断有无三个连续的元音或辅音字母
if(strlen(s)<3) return true;
for(int i=0;i<strlen(s)-2;i++)
if(yuanfu[s[i]-'a']==yuanfu[s[i+1]-'a']&&yuanfu[s[i+1]-'a']==yuanfu[s[i+2]-'a'])
return false;
return true;
}
bool erlian(char s[]){//推断有无两个连续同样非ee或oo字母
if(strlen(s)<2) return true;
for(int i=0;i<strlen(s)-1;i++)
if(s[i]==s[i+1]&&!(s[i]=='e'||s[i]=='o'))
return false;
return true;
}
int main(){
char s[110];
yuanfu[0]=yuanfu[4]=yuanfu[8]=yuanfu[14]=yuanfu[20]=1;
while(scanf("%s",s)!=EOF&&strcmp(s,"end")){
if(!yuan(s)) printf("<%s> is not acceptable.\n",s);
else if(!sanlian(s)) printf("<%s> is not acceptable.\n",s);
else if(!erlian(s)) printf("<%s> is not acceptable.\n",s);
else printf("<%s> is acceptable.\n",s);
}
return 0;
}

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

HDU 1039.Easier Done Than Said?【字符串处理】【8月24】的更多相关文章

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

    Easier Done Than Said?                                                                     Time Limi ...

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

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

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

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

  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 1042.N!【高精度乘法】【8月24】

    N! Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N ...

  7. 字符串 HDU 1039

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

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

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

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

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

随机推荐

  1. Shiro:初识Shiro及简单尝试

    Shiro 一.什么是Shiro Apache Shiro是Java的一个安全(权限)框架 作用:认证.授权.加密.会话管理.与web集成.缓存等 下载地址:http://shiro.apache.o ...

  2. tp框架,addAll方法报错,返回false

    tp框架的批量添加addAll($data)方法很实用,但是注意,数据数组的数据结构要保持一致,不然会返回false.

  3. 【【henuacm2016级暑期训练】动态规划专题 E】Destroying Roads

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 首先. 这张图是无向无权图. 因此任意两点之间的最短路可以通过N^2的bfs轻易算出来. 即得到d[N+10][N+10] 考虑s[ ...

  4. 循环语句第2种 WHILE ... LOOP END LOOP;

     --------第2种--------   WHILE ... LOOP   END LOOP;    declare    n number(3) :=1;  begin    WHILE n&l ...

  5. 获取ip,判断用户所在城市

    PHP获取IP地址 这个比较简单了,利用PHP自带函数就可以了,PHP中文手册看一下,都有现成的例子,就不过多说明了,直接上代码,A段: <? //PHP获取当前用户IP地址方法 $xp_Use ...

  6. angular-HTML DOM

    ng-disabled用法 <div ng-app="" ng-init="mySwitch=true"> <p> <button ...

  7. POJ 3270

    黑书上的经典题了.我说说解这个题的巧妙的地方吧. 首先,竟然和置换联系起来了.因为其实一个交换即至少可以使其中一个元素到达指定位置了.和循环置换联合起来,使得一个循环内的数可以一步到达指定位置,很巧妙 ...

  8. Chrome的JSON View插件

    Chrome的JSON View插件 学习了:http://www.cnplugins.com/zhuanti/five-chrome-json-plugins.html 下载了:http://www ...

  9. 算法 - 求一个数组的最长递减子序列(C++)

    //************************************************************************************************** ...

  10. iOS知识点汇总

    1.怎样追踪app崩溃率.怎样解决线上闪退 当iOS设备上的App应用闪退时.操作系统会生成一个crash日志.保存在设备上.crash日志上有非常多实用的信息,比方每个正在运行线程的完整堆栈跟踪信息 ...