规则:

1.必须至少包含一个元音字母。a e i o u

2.不能包含三个连续元音或者连续辅音字母。

3.不能包含两个连续字母,除了'ee'和'oo'。

PS:字母个数(1<= N <=20).

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include <string.h> int is_vowel(char strIn)
{
if(strIn == 'a' || strIn == 'e' ||strIn == 'i' || strIn == 'o' || strIn == 'u')
return ;
else
return ;
} void main()
{
while()
{
char strIn[] = {'\0'};
char strTemp[] = {'\0'}; //字符缓存,用于判断是否连续出现相同字符
char temp;
int count = ; //统计连续相同字母个数
int count2 = ; //统计连续的元音或者辅音字母个数
int vowelFlag = ; //是否元音的标志位
int lastIsVowel = ; //上一个字母是否是元音的标志位 0 不是 1 是
int sign = ; //是否含有元音标志位
int resultFalg = ;
int len; //保存输入的字符串的长度
gets(strIn);
len = (int)strlen(strIn);
//先判断是否是结束查询标志
if(strcmp(strIn, "end") == )
return;
temp = strIn[];
count = ;
count2 = ;
vowelFlag = is_vowel(strIn[]);
lastIsVowel = is_vowel(strIn[]);
//查找是否包含元音字母,如果遇到连续3个元音字母,辅音字母或者连续2个除了'ee''oo'之外的相同字母,则判断为不可接受,并退出循环
for(int i = ; i < len; i++)
{
if(sign == )
sign = is_vowel(strIn[i]);
//如果出现相同的字母
if(i > && temp == strIn[i])
{
count++;
if(count == )
{
if(temp != 'e' && temp != 'o')
{
resultFalg = ; //不可接收,跳出循环
break;
}
}
}
//如果出现三个连续元音或连续三个辅音
if(i > )
{
vowelFlag = is_vowel(strIn[i]);
if(vowelFlag == lastIsVowel)
{
count2++;
if(count2 >= )
{
resultFalg = ; //不可接收,跳出循环
break;
}
}
else
{
count2 = ;
lastIsVowel = vowelFlag;
} }
temp = strIn[i];
count = ; } if(sign == && resultFalg != )
{
printf("<%s> is acceptable.", strIn );
printf("\n");
}
else
{
printf("<%s> is not acceptable.", strIn );
printf("\n");
}
}
}

字符串 HDU 1039的更多相关文章

  1. HDU 1039(字符串判断 **)

    题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件 ...

  2. hdu 1039 Easier Done Than Said? 字符串

    Easier Done Than Said?                                                                     Time Limi ...

  3. HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)

    Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy ...

  4. HDU 1039.Easier Done Than Said?-条件判断字符串

    Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...

  5. HDU 1039.Easier Done Than Said?【字符串处理】【8月24】

    Easier Done Than Said? Problem Description Password security is a tricky thing. Users prefer simple ...

  6. 题解报告:hdu 1039 Easier Done Than Said?

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 Problem Description Password security is a trick ...

  7. (DFS)展开字符串 -- hdu -- 1274

    http://acm.hdu.edu.cn/showproblem.php?pid=1274 展开字符串 Time Limit: 2000/1000 MS (Java/Others)    Memor ...

  8. hdu 1039 (string process, fgets, scanf, neat utilization of switch clause) 分类: hdoj 2015-06-16 22:15 38人阅读 评论(0) 收藏

    (string process, fgets, scanf, neat utilization of switch clause) simple problem, simple code. #incl ...

  9. HDU 1039 -Easier Done Than Said?

    水水的 #include <iostream> #include <cstring> using namespace std; ]; bool flag; int vol,v2 ...

随机推荐

  1. 用ajax查询天气

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src ...

  2. [LeetCode] Decode String 解码字符串

    Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where ...

  3. 自动化运维工具ansible部署以及使用

    测试环境master 192.168.16.74webserver1 192.168.16.70webserver2 192.168.16.72安装ansiblerpm -Uvh http://ftp ...

  4. 资源描述结构(Resource Description Framework,RDF)

    资源描述框架(Resource Description Framework),一种用于描述Web资源的标记语言.RDF是一个处理元数据的XML(标准通用标记语言的子集)应用,所谓元数据,就是" ...

  5. Gulp:自动化构建工具

    一.介绍: gulp是一个基于流的构建工具,可以自动执行指定的任务,简洁且高效 二.优点: 开发环境下,想要能够按模块组织代码,监听实时变化 css/js预编译,postcss等方案,浏览器前缀自动补 ...

  6. .技术参数图用pillow自动处理

    python 2.7 pillow 安装python2.7.10(自带pip),修改豆瓣源,下载pillow

  7. MYSQL (二)

    视图: 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用. 1.  尽量使用视图完成读操作 2. ...

  8. 渗透测试-信息收集-c段收集

    平时做渗透测试我比较喜欢用lijiejie 写的 subDomainsBrute来爆破子域名 那么爆破完成后就想收集一下网站的c段信息 下面以平安为例 爆破得到子域名为 i.pingan.com.cn ...

  9. Dictionary

    命名空间:System.Collections.Generic(程序集:mscorlib) Dictionary<TKey, TValue> 类   一般用法:通过key获取value,k ...

  10. javascript事件操作

    这里使用一个图片切换的方法来举例说明,如何通过代码操作事件. 1 通过html属性处理事件 <img id='avatar1' src="http://7u2gej.com1.z0.g ...