字符串 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 ...
随机推荐
- CentOS7中防火墙的一些常用配置
# 启动 systemctl start firewalld # 查看状态 systemctl status firewalld # 停止关闭 systemctl disable firewalld ...
- Unity 重要基础知识点
这是两个月前的学习记录,发出来了下,如果有误欢迎大家指出: 脚本生命周期 //每当脚本被加载时调用一次 // 1. 在Awake中做一些初始化操作 void Awake(){ //初始化publi ...
- NodeJS、NPM安装配置步骤(windows版本)
windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到首页的"INSTA ...
- Linux ——————用Secure传文件时直接拖了文件用的是AssIC导致linux那边直乱码
如下: 解决办法: 直接删除.
- 2016BUAA校赛决赛
A. 题意:有n个点,n-1条边,1-2-3-4-5-...-n,每条边都有权值,代表走这条边的时间,时刻0一个人在点1,问从时刻1~m,有哪些时刻这个人可能走到n点 分析:将每条边当作物品,可以选1 ...
- express不是内部或外部命令
网上找了一下原因,是因为express在4.0以后把命令工具单独分出来了,所以安装完express后,还得再安装express-generator: 如果不是采用的全局安装,则需要把 "安装 ...
- JQuery选择器
动态修改样式 $("#div1").attr("display","block"); //有问题 $("#div1"). ...
- css 的一些基本操作
日常基本使用的一些操作,持续完善中: 设置按钮圆角:border-radius:5px; 设置高度:height: 30px; 设置宽度:width: 64px; 使用span标签内容过长自动换行解决 ...
- 【BZOJ 1494】【NOI 2007】生成树计数
http://www.lydsy.com/JudgeOnline/problem.php?id=1494 这道题..因为k很小,而且我们只关心连续的k个节点的连通性,所以把连续的k个点轮廓线上的连通性 ...
- iOS推送流程
1. 在apple开发者帐号上创建一个BundleID,创建证书或者Xcode上都是用这个BundleID(例如com.mycompany.pushDemo) 2. 代码层面: 在capability ...