字符串 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 ...
随机推荐
- 使用maven给spring项目打可直接运行的jar包(配置文件内置外置的打法)
从网上看过许多打jar包的例子,大多是将配置文件打进jar包的.经过本人一番研究,终于搞清楚了怎样将jar包的配置文件外置. 废话不说,直接上spring的pom.xml的配置文件. <proj ...
- [LeetCode] Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最小共同父节点
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...
- 基于C/S架构的3D对战网络游戏C++框架_05搭建系统开发环境与Boost智能指针、内存池初步了解
本系列博客主要是以对战游戏为背景介绍3D对战网络游戏常用的开发技术以及C++高级编程技巧,有了这些知识,就可以开发出中小型游戏项目或3D工业仿真项目. 笔者将分为以下三个部分向大家介绍(每日更新): ...
- background-image和img的区别
background-img的时候外边的div必须有宽和高.并且你只能决定图片位于你div的位置不能拉伸图片,或者改变图片的宽高.但是background-image是可以重复的,所以只要你的图片不是 ...
- web前端开发中常用的尺寸和位置
我们在日常web前端开发过程中,会经常用到各种尺寸和位置.通常是js做动画的时候.轮播图,滚屏动画,粒子,碰撞检测,拖拽,滚动加载等等.这里我将常用的尺寸和位置的获取进行总结,不包括canvas,SV ...
- FtpUtil
/* * 文件名:FtpUtil.java * 版权:Copyright 2000-2007 Huawei Tech. Co. Ltd. All Rights Reserved. * 描述: TopE ...
- c#常用方法
创建目录 Directory.CreateDirectory(Application.StartupPath+"\\test");
- 43. Multiply Strings
/** * @param {string} num1 * @param {string} num2 * @return {string} */ var multiply = function(num1 ...
- java-w3c.document生成xml文件
案例 /** * 创建和写入xml * @param xmlrootname * @param waitConverList */ private void createAndWriterXML(St ...
- C# 在数组中判断是否存在某个数组值
(1) 第一种方法: ,,}; ); // 这里的1就是你要查找的值 ) // 不存在 else // 存在 (2) 第二种方法: string[] strArr = {"a",& ...