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. ThinkPhp调用webservice

    模板页: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  2. js中document的用法

    document.title //设置文档标题等价于HTML的title标签document.bgColor //设置页面背景色document.fgColor //设置前景色(文本颜色)docume ...

  3. webservice 技术改进

    Webservice 技术改进 1.不同系统不同语言之间的交互 基于http协议进行传输,使用REST服务实现WS 2.不同系统相同语言之间的交互 使用RPC(romate process call) ...

  4. css案例学习之双斜角横线菜单

    效果 代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  5. SQL数据转移

    方法一:如果想把数据库A中的表Table1中的数据复制到数据库B中的表Table2中,也就是要预先建立Table2,可以使用一下语句: use B goinsert into Table2 selec ...

  6. 一 VC2008环境中ICE的配置

    VC2008环境中ICE的配置 ICE 3.4.0的下载页面 http://www.zeroc.com/download_3_4_0.html 环境变量配置  1.Ice-3.4.0安装到c:\Ice ...

  7. 《Java web 开发实战经典》读书笔记

    去年年末,也就是大四上学期快要结束的时候,当时保研的事情确定了下来,终于有了一些空闲的时间可以学点实用的技术. 之前做数据库课程设计的时候,也接触过java web的知识,当时做了一个卖二手书籍的网站 ...

  8. GridBagLayout占多行效果注意

    如果想要出现按钮2占两行的效果,必须按键3.按钮4同时存在且同时可见. 如果缺少按钮4,则按钮2不会占两行: 如果缺少按钮3.4,则按钮2也不会占两行. package com.wst.bj; imp ...

  9. distinct() 去重复

    distinct 是对整个结果集进行数据重复抑制,而不是针对每一个列. select distinct FDepartment from T_Employee

  10. 【转】android电池(四):电池 电量计(MAX17040)驱动分析篇

    关键词:android 电池  电量计  MAX17040 任务初始化宏 power_supply 平台信息:内核:linux2.6/linux3.0系统:android/android4.0 平台: ...