字符串 HDU 1039
规则:
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的更多相关文章
- HDU 1039(字符串判断 **)
题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件 ...
- hdu 1039 Easier Done Than Said? 字符串
Easier Done Than Said? Time Limi ...
- HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)
Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy ...
- HDU 1039.Easier Done Than Said?-条件判断字符串
Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
Easier Done Than Said? Problem Description Password security is a tricky thing. Users prefer simple ...
- 题解报告:hdu 1039 Easier Done Than Said?
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 Problem Description Password security is a trick ...
- (DFS)展开字符串 -- hdu -- 1274
http://acm.hdu.edu.cn/showproblem.php?pid=1274 展开字符串 Time Limit: 2000/1000 MS (Java/Others) Memor ...
- 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 ...
- HDU 1039 -Easier Done Than Said?
水水的 #include <iostream> #include <cstring> using namespace std; ]; bool flag; int vol,v2 ...
随机推荐
- shell两数之间的算术运算
#!/bin/bash read -p "请输入第一个数:" a read -p "请输入第二个数:" b echo "$a+$b=$[$a+$b]& ...
- MYSQL 导入Excel数据到数据库中
1,先把excel的数据整理整齐,如每列都要保持同样的格式:就一列一列的数据: 2,导出excel的数据为CSV格式,即把excel的数据另存为xxxx.csv;: 3,用EditPlus工具将xxx ...
- [python]python try异常处理机制
#python的try语句有两种风格 #一:种是处理异常(try/except/else) #二:种是无论是否发生异常都将执行最后的代码(try/finally) try/except/else风格 ...
- Ubuntu 一直掉线 以及连不上网 解决办法
新装了一个Ubuntu 系统16.04才使用的时候一切顺利 但是过了两三天 就会出现 频繁掉线的情况 于是上网找大神们的解决办法 把文件 /etc/ppp/options 里面的一个数值改大一点 l ...
- [No0000A0]批处理命令学习之:常用的特殊符号
学习要点:1.>.>>重定向符2.| 命令管道符3.&.&&.|| 组合命令4.^ 转义字符5.% 变量引导符6."" 界定符—————— ...
- Node.js包管理器Yarn的入门介绍与安装
FAST, RELIABLE, AND SECURE DEPENDENCY MANAGEMENT. 就在昨天, Facebook 发布了新的 node.js 包管理器 Yarn 用以替代 npm .咱 ...
- codevs 1164 统计数字
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题目描述 Description [问题描述]某次科研调查时得到了n个自然数,每个数均不超过150000000 ...
- Zend Framework 项目 index.php 的问题
默认生成的Zend项目在public目录下会自动生成一个.htaccess文件,这是用来实现伪静态,即隐藏index.php这个唯一入口文件的. 但是,搭建项目时遇到一个问题:URL中如果不加inde ...
- NIO服务器
导语 NIO的出现是为服务器端编程而设计的.它的作用就是能够让一个线程为多个连接服务.NIO中的API都是非阻塞模式的,这样可以在服务器端采用异步的方式来处理多个请求.NIO中有两个重要的东西就是通道 ...
- GD库常用函数
创建句柄 imagecreate($width, $height) //新建图像 imagecreat ...