字符串水题(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); 功能: 分解 ...
随机推荐
- web_profile(网站分析)配置
web_profiler: # DEPRECATED, it is not useful anymore and can be removed # safely from your configura ...
- 处理PHP中字符串的常用操作及函数
1. 确定一个字符串的长度 这是最为常见和基础的例子,对于确定一个字符串的长度,我们应该使用strlen()函数,比如要获取下面字符串$text 的长度: $text = "sunny da ...
- zabbix之1监控概念
1.通过通用的snmp监控,无需代理端 2.通过snmp代理 snmp代理的工作原理:在被监控端设置代理,代理不断的获取本地数据,而管理端定期通过代理获取监控数据. snmp目前有v1,v2,v3三种 ...
- 关于python的面向对象编程
先写上代码,有代码才好理解: #filename:classdemo.py class test: '''just person''' a=1 b=2 c=0 def __init__(self): ...
- javaweb jsp页面上传excel文件
servlet: private static final long FILE_MAX_SIZE = 4 * 1024 * 1024; if (!ServletFileUpload.isMultipa ...
- Service、Alarm与BroadcastReceiver的使用方法
1:定义一个服务类,在服务类中使用AlarmManager 来管理服务的运行 public class WtacService extends Service{ private AlarmManage ...
- java学习之Java中JDK,JRE和JVM之间的关系(转载)
最近要重新抓一下java,大量扫技术文档,保存下来供自己查阅.以下转载自http://www.cnblogs.com/xiaofeixiang/p/4085159.html 初学JAVA很容易被其中的 ...
- Mybatis的连接池
先总结一个原则:mytatis的连接池最大值poolMaximumActiveConnections尽量跟服务器的并发访问量持平以至于大于并发访问量. 原因:在org.apache.ibatis.da ...
- Apache、php、mysql单独安装配置
php, 安装版的,http://www.php.net/manual/zh/install.php.也有不安装版直接配置的. 在Windows 7下如何进行PHP配置环境. PHP环境在Window ...
- android:强大的图片下载和缓存库Picasso
1.Picasso简单介绍 Picasso是Square公司出品的一个强大的图片下载和缓存图片库.官方网址是:http://square.github.io/picasso/ 仅仅须要一句代码就能够将 ...