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.
#include <cstdio>
#include <algorithm>
#define MAXLEN 22
char password[MAXLEN];
int main() {
//freopen("input.txt","r",stdin);
int nc,nv,vcnt, invalid;
char *p;
while(scanf("%20s",password)==1 && strcmp(password,"end")!=0) {
nc=nv=vcnt=0; invalid=0;
p=password-1;
while(*++p) {
switch(*p) {
case 'e':
case 'o':
case 'a':
case 'i':
case 'u':
++vcnt; ++nv; nc=0; break;
default:
++nc; nv=0; break;
}
if(*p==*(p+1) && *p!='e' && *p!='o') { invalid=1; break; }
if(nc>2 || nv>2) { invalid=1; break; }
}
if(invalid || vcnt==0) printf("<%s> is not acceptable.\n",password);
else printf("<%s> is acceptable.\n",password);
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。// p.s. If in any way improment can be achieved, better performance or whatever, it will be well-appreciated to let me know, thanks in advance.
hdu 1039 (string process, fgets, scanf, neat utilization of switch clause) 分类: hdoj 2015-06-16 22:15 38人阅读 评论(0) 收藏的更多相关文章
- Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏
胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Subm ...
- Digital Roots 分类: HDU 2015-06-19 22:56 13人阅读 评论(0) 收藏
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- u Calculate e 分类: HDU 2015-06-19 22:18 14人阅读 评论(0) 收藏
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- Hdu 1009 FatMouse' Trade 分类: Translation Mode 2014-08-04 14:07 74人阅读 评论(0) 收藏
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1034 (preprocess optimization, property of division to avoid if, decreasing order process) 分类: hdoj 2015-06-16 13:32 39人阅读 评论(0) 收藏
IMO, version 1 better than version 2, version 2 better than version 3. make some preprocess to make ...
- string 与char* char[]之间的转换 2015-04-09 11:30 29人阅读 评论(0) 收藏
1.首先必须了解,string可以被看成是以字符为元素的一种容器.字符构成序列(字符串).有时候在字符序列中进行遍历,标准的string类提供了STL容器接口.具有一些成员函数比如begin().en ...
- HDU 1754 I Hate It 2016-09-14 19:01 27人阅读 评论(0) 收藏
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏
errors made, boundary conditions, <= vs < , decreasing vs increasing , ++, –, '0'/'1' vs 0/1 p ...
随机推荐
- WORD自定义宏
自定义快捷键 折叠所有标题 Word选项—自定义功能区—自定义键盘—不在功能区内的命令—ColllapseAllHeadings 展开所有标题 Word选项—自定义功能区—自定义键盘—不在功能区内的命 ...
- 批处理命令——choice
[1]choice命令简介 使用此命令可以提示用户输入一个选择项,根据用户输入的选择项再决定执行具体的过程. 使用时应该加/c:参数,c: 后应写提示可输入的字符或数字,之间无空格.冒号是可选项. 使 ...
- 查看Linux内核版本命令
一.查看Linux内核版本命令(两种方法): .cat /proc/version .uname -a 二.查看Linux系统版本的命令(3种方法): .lsb_release -a即可列出所有版本信 ...
- vs2010下编译osip2和eXosip2的4.0.0版的静态库及搭建开发环境
转载于:http://blog.csdn.net/lbc2100/article/details/48293911 本文为参考网上的动态库的方式,进行静态库的实现,在此对动态库的作者表示感谢. 第一步 ...
- 关于jstl标签引入的问题
1.源码: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> < ...
- CSS中的浮动问题
有关于我们经常做的导航问题.我们如果想用ul>li来做导航的话,我是一般是用到浮动这个属性的. 也就是 float:left; 或者是 display:inline-block; 下边代码: ...
- [问题2014A03] 解答
[问题2014A03] 解答 注意到 \((A^*)^*\) 的第 (1,1) 元素是 \(A^*\) 的第 (1,1) 元素的代数余子式, 即为 \[\begin{vmatrix} A_{22} ...
- java关于时间
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Created b ...
- Ubuntu快捷键
https://linux.cn/article-3025-1.html 超级键操作 1.超级键(Win键)–打开dash. 2.长按超级键– 启动Launcher.并快捷键列表. 3.按住超级键,再 ...
- (二)Kafka动态增加Topic的副本(Replication)
(二)Kafka动态增加Topic的副本(Replication) 1. 查看topic的原来的副本分布 [hadoop@sdf-nimbus-perf ~]$ le-kafka-topics.sh ...