Easier Done Than Said?
来源:互联网 发布:linux apache启动命令 编辑:程序博客网 时间:2024/05/22 22:36
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.
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
atvptouibontreszoggaxwiinqeephouctuhend
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个元音或者是辅音(我是想也就是说每三个元音和辅音都要大于1) 3.相邻的不可以相等
#include <stdio.h>#include <stdlib.h>#include<string.h>int main(){ char str[40]; int n,m,i,j; while(gets(str)!=NULL) { int a=0,b=0,c=0,s=0,flag,flag1,flag2; if(strcmp(str,"end")==0) break; n=strlen(str); for(i=0; i<n; i++) { if(str[i]=='a') ++s; if(str[i]=='e') ++s; if(str[i]=='i') ++s; if(str[i]=='o') ++s; if(str[i]=='u') ++s; } if(s>=1) flag=1; else flag=0; if(n==1||n==2) flag1=1; else { for(i=0; i<n-2; i++) { int x=0,y=0; for(j=i; j<i+3; j++) { if(str[j]=='a'||str[j]=='i'||str[j]=='e'||str[j]=='o'||str[j]=='u') ++x; if(str[j]!='a'&&str[j]!='i'&&str[j]!='e'&&str[j]!='o'&&str[j]!='u') ++y; } if(x>=1&&y>=1) ++b; } if(b==n-2) flag1=1; else flag1=0; } if(n==1) flag2=1; else { for(i=0; i<n-1; i++) { if(str[i]!=str[i+1]||str[i]=='e'||str[i]=='o') ++c; } if(c==n-1) flag2=1; else flag=0; } if(flag==1&&flag1==1&&flag2==1) printf("<%s> is acceptable.\n",str); else printf("<%s> is not acceptable.\n",str); } return 0;}
0 0
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- hdu Easier Done Than Said?
- 1039 Easier Done Than Said?
- 题目:Easier Done Than Said?
- HDU1039:Easier Done Than Said?
- TJU Easier Done than Said?
- HDU1039:Easier Done Than Said?
- 1911. Easier Done than Said?
- Keep on Truckin
- 计算中文混合字符串长度(二)
- Zend Studio 无法打开的解决办法
- Biker's Trip Odometer
- 基于easyui的验证扩展
- Easier Done Than Said?
- vim配置(centos安装系列4)
- Ubuntu安装Java多版本的新方法
- 学习阅读源代码
- Climbing Worm
- Linux内核
- cocos2d-x中用singleton(单例)设计模式共享数据
- Text Reverse
- 关于TOGAF认证考试