hdu 1039 (string process, fgets, scanf, neat utilization of switch clause) 分类: hdoj 2015-06-16 22:15 38人阅读 评论(0) 收藏
2024-10-16 23:21:08
(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.
最新文章
- ubuntu15:10 163源
- jQuery实现AJAX定时刷新局部页面实例
- 版本管理之Git(二):Win7上Git安装及简单配置过程
- js比typeof更准确的验证类型方法
- Session案例:简易的购物车
- Delete website with command.
- BZOJ 1036: [ZJOI2008]树的统计Count( 树链剖分 )
- SVN学习之windows下svn的安装
- 【腾讯海纳】系统未发布时如何获取获取property_id在本地进行测试?
- 洛谷P1996 约瑟夫问题【链表】
- [C#]将数据写入已存在的excel文件
- 20. Web proxies (网页代理 4个)
- MVC HtmlHelper用法
- javascript 模拟日历
- cocos2d-x JS 字符串
- Linux 运维测试及第三应用及测试工具
- 每日英语:Boost Your Balance; Avoid Falls
- 用ARM实现音乐电子相册
- IT管理就这么管
- shell 字符串运算符
热门文章
- Hadoop编程1:天气数据AWK &; MapReduce
- url结构说明
- phpcms无法读取index.html的解决步骤
- win7 APPCRASH问题解决!
- GRUB学习笔记(转自http://www.cnblogs.com/evilzy/archive/2008/03/30/1130173.html)
- [转]关于NSAutoreleasePool&#39; is unavailable: not available in automatic reference counting mode的解决方法
- android 内存处理工具
- if,else语句的运用
- 【Nginx】配置Nginx的负载均衡
- ibatis mybatis sql语句配置 符号不兼容 大于号 小于号<;!CDATA[ ]>;