字符串水题(hdoj1049)
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.
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.
acceptable, using the precise format shown in the example.
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end
#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)的更多相关文章
- 1222: FJ的字符串 [水题]
1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1 = “A” A2 = ...
- 1001 字符串“水”题(二进制,map,哈希)
1001: 字符串“水”题 时间限制: 1 Sec 内存限制: 128 MB提交: 210 解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- HDU ACM 1073 Online Judge ->字符串水题
分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...
- HDU4891_The Great Pan_字符串水题
2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍 题目:http://acm.hdu.edu.cn/showproblem.php?pid=48 ...
- 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 ...
- 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 ...
- uva 10252 - Common Permutation 字符串水题
题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...
- hdu1106 字符串水题strtok()&&strchr()&&sscanf()+atoi()使用
字符串的题目 用库函数往往能大大简化代码量 以hdu1106为例 函数介绍 strtok() 原型: char *strtok(char s[], const char *delim); 功能: 分解 ...
随机推荐
- PLSQL在cmd命令行中的基本用法
首先:set serveroutput on:设置打印 declareresult number;beginselect (sal*12)+nvl(comm,0) into result from e ...
- 禁用ubuntu的触摸板和独显
#!/bin/bash #This is a vgaoff & touchpadoff #By spinestars #-2-18#TouchPad & VGA OFF == ];th ...
- Python学习(六) Python数据类型:字典(重要)
字典dict: 字典其实就相当于java里面的Map,用来存储键值对的.其中存储的数据时无序的. 假如有这样的数据: t1=['name','age','sex'] t2=['tom',30,'mal ...
- Java Spring MVC
Spring MVC的实现包括 实现Controller类和基于注解的Controller RequstMapping方式 依赖: <!-- https://mvnrepository.com/ ...
- linux服务器之间拷贝文件和文件夹
传输文件用法:scp 本机文件目录 远程服务器用户名@服务器IP:/服务器目录 示例:
- SQL Server 索引的自动维护 <第十三篇>
在有大量事务的数据库中,表和索引随着时间的推移而碎片化.因此,为了增进性能,应该定期检查表和索引的碎片,并对具有大量碎片的进行整理. 1.确定当前数据库中所有需要分析碎片的表. 2.确定所有表和索引的 ...
- yii安装配置
Yii 的安装由如下两步组成: 从 yiiframework.com 下载 Yii 框架. 将 Yii 压缩包解压至一个 Web 可访问的目录. 提示: 安装在 Web 目录不是必须的,每个 Yii ...
- 【转】6.4.6 将驱动编译进Linux内核进行测试
原文网址:http://www.apkbus.com/android-98520-1-1.html 前面几节都是将Linux驱动编译成模块,然后动态装载进行测试.动态装载驱动模块不会随着Android ...
- 不可或缺的企业OA面临问题,以及解决建议 软件定制开发 森普演示平台
---恢复内容开始--- 随着信息时代的来临,企业管理也相应的信息化,各种管理软件相继而出,各行各业的信息化有过成功,也有过失败(注:是以该项目是否达到用户的预期目标而言).据统计在信息化失败的案例中 ...
- java打印菱形的简单方法
代码: public class Diamond { /** * 测试main方法 */ public static void main(String[] args) { printDiamond(1 ...