字符串 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 ...
随机推荐
- css权重计算方法浅谈
在这之前只知道css权重的皮毛,比如说:行内权重比头部权重高,头部比外部样式权重高----工作中才知道真正理解css权重重要性.理解权重了才能写出来最优css选择器来.对后面学习less,scss有很 ...
- ubuntu 14.04安装pypcap
直接sudo apt-get install python-pypcap即可 How to install python-pypcap on Ubuntu 12.04 (Precise Pangoli ...
- [LeetCode] Largest Divisible Subset 最大可整除的子集合
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...
- [LeetCode] Closest Binary Search Tree Value 最近的二分搜索树的值
Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...
- sql server 公共表达式的简单应用(cte)
一.前言 现在做项目数据访问基本都会选择一种orm框架,它以面向对象的形式屏蔽底层的数据访问形式,让开发人员更集中在业务处理上,而不是和数据库的交互上,帮助我们提高开发效率:例如一些简单的insert ...
- 迁移 SQL Server 数据库到 Azure SQL 实战
最近有个维护的项目需要把 SQL Server 2012 的数据库迁移到 Azure SQL 上去,迁移过程可谓一波三折,故在此分享这次迁移中碰到的点点滴滴,希望对朋友们有所帮助. 文章来源:葡萄城产 ...
- jq封装淘宝图片轮播插件
<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/htm ...
- 关于Django 错误 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
记录一下 报错 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS\ 这个问题出现没 ...
- 未在本地计算机上注册“Microsoft.Jet.OleDb.4.0”提供程序。解决办法
在64位服务器系统上,默认不支持Microsoft.Jet.OLEDB.4.0的驱动程序,系统默认会提示未在本地计算机上注册"Microsoft.Jet.OLEDB.4.0"的错误 ...
- ubuntu中phpmyadmin密码忘记
在安装mysql时,默认只让你设置了root的密码,如果root的密码忘记,处理办法如下 第一步: 这时你需要进入/etc/mysql目录下,然后sudo vim/vi debian.cnf查看里面的 ...