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.
 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char b[]={'a','e','i','o','u'},c[]={'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'};
char d[]={'a','i','u','b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'};
char a[];
int len;
int vowels()
{
int i,k,j;
int flag;
for(i=;i<len-;i++)
{
flag=;
for(j=;j<;j++)
{
for(k=;k<;k++)
{
if(a[i+j]==b[k])
{
flag++;
break;
}
}
}
if(flag==)
return ;
}
return ;
}
int consonants()
{
int i,k,j;
int flag;
for(i=;i<len-;i++)
{
flag=;
for(j=;j<;j++)
{
for(k=;k<;k++)
{
if(a[i+j]==c[k])
{
flag++;
break;
}
}
}
if(flag==)
return ;
}
return ;
}
int consecutive_occurrences()
{
int i,j,k;
bool flag;
for(i=;i<len-;i++)
{
flag=;
if(a[i]==a[i+])
{
for(j=;j<;j++)
if(a[i]==d[j])
{
flag=;
break;
}
}
if(flag)
return ;
}
return ;
}
int main()
{
char b[]="end";
while(cin>>a)
{
getchar();
if(strcmp(a,b)==)
break;
len=strlen(a);
int k=;
if((strchr(a,'a')!=NULL)||(strchr(a,'e')!=NULL)||(strchr(a,'i')!=NULL)||(strchr(a,'o')!=NULL)||(strchr(a,'u')!=NULL))
k++;
if(vowels()&&consonants())
k++;
if(consecutive_occurrences ())
k++;
if(k==)
cout<<'<'<<a<<'>'<<" is acceptable."<<endl;
else
cout<<'<'<<a<<'>'<<" is not acceptable."<<endl;
memset(a,,sizeof(a));
}
}

字符串水题(hdoj1049)的更多相关文章

  1. 1222: FJ的字符串 [水题]

    1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1  =  “A” A2  =   ...

  2. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  3. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  4. HDU ACM 1073 Online Judge -&gt;字符串水题

    分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...

  5. HDU4891_The Great Pan_字符串水题

    2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍 题目:http://acm.hdu.edu.cn/showproblem.php?pid=48 ...

  6. Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题

    B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...

  7. Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题

    A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  8. uva 10252 - Common Permutation 字符串水题

    题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...

  9. hdu1106 字符串水题strtok()&&strchr()&&sscanf()+atoi()使用

    字符串的题目 用库函数往往能大大简化代码量 以hdu1106为例 函数介绍 strtok() 原型: char *strtok(char s[], const char *delim); 功能: 分解 ...

随机推荐

  1. css使用技巧

    1) 网站上经常会出现用户输入一大段字符和字母以至于文字无法正常折行,把版式破坏,这样我们就要参考以下样式:word-wrap:break-word; overflow:hidden; 当然必须得有宽 ...

  2. ReferenceError: $ is not defined

    蛋疼的问题,原因是jquery导入顺序不对,任何页面都必须把jquery的导入放在首位,js文件放在其次.

  3. 三维地图(BFS)

    亡命逃窜 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 从前有个叫hck的骑士,为了救我们美丽的公主,潜入魔王的老巢,够英雄吧.不过英雄不是这么好当的.这个可怜的娃 ...

  4. select操作

    // 1.判断select选项中 是否存在Value="paraValue"的Item         function jsSelectIsExitItem(objSelect, ...

  5. mongodb操作记录

    [User]1.db.addUser("name","pwd","true/false")2.db.auth("name" ...

  6. BZOJ NOI十连测 第二测 T2

    思路:20%可以搜索.. #include<algorithm> #include<cstdio> #include<cmath> #include<cstr ...

  7. QObject就有eventFilter,功能很强(随心所欲的进行处理,比如用来QLineEdit分词)

    相信大家都用过词典吧!因为英语不太好...O(∩_∩)O~,所以经常进行划词翻译! 简述 实现 效果 源码 更多参考 实现 原理:鼠标移至某单词之上,获取鼠标位置,然后在对应位置进行取词,翻译! 基于 ...

  8. jQuery之位置

    1.offset()获取匹配元素在相对浏览器窗口的偏移量 返回一个对象,包括两个属性.left:相对浏览器窗口左边的距离.top:相对浏览器顶部的距离.  $("#div1").o ...

  9. MATLAB三维曲面

    今天终于测试了,发下来第一张试卷中只会做一小题.我蒙了!!! 所以呢,我现在再做一下,总结总结! 作函数 f(x)=2(x1-1)4+2x22 的三维图. 这道题要用到的知识点有函数meshgrid. ...

  10. OpenWrt编译

    OpenWrt编译简单过程1,OpenWrt编译环境准备sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoco ...