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="">

最新文章

  1. zabbix监控报错zabbix server is not running解决方法
  2. 网页中的&lt;th&gt;&lt;/th&gt;是什么意思
  3. iOS安全—阻止tweak注入hook api
  4. 从零开始PHP攻略(2)——操作符与迭代整理
  5. 使用POI导入Excel异常Cannot get a text value from a numeric cell 解决
  6. 关于ShareSDK接入的各种问题,以及解决方案
  7. HW5.12
  8. Android Proguard
  9. 几种快速傅里叶变换(FFT)的C++实现
  10. vue怎么样创建组件呢??
  11. [国嵌攻略][059][2440-DMA程序设计]
  12. FormsAuthenticationTicket
  13. 【Android】LMK 工作机制
  14. VMware vSphere Client(Vcenter)上传ISO镜像
  15. 如何在CentOS 7上安装Munin
  16. python day 09 文件操作
  17. 【代码笔记】iOS-只让textField使用键盘通知
  18. Spring学习笔记--Spring表达式语言SpEL
  19. Java 语言结构【转】
  20. struts2把表单数据封装到实体类里

热门文章

  1. ucore_lab1
  2. 机器学习关于AUC的理解整理
  3. Webserver管理系列:4、WinPE
  4. PHP静态延迟绑定简单演示样例
  5. MyEclipse中安装Testng插件
  6. @dynamic与@synthesize的差别
  7. Linux部署之批量自动安装系统之NFS篇
  8. js&amp;jQ判断checkbox表单是否被选中
  9. FCC高级编程篇之Record Collection
  10. (转)String StringBuilder StringBuffer 对比 总结得非常好