hdu2072
注意输入全是0的情况。
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
bool cmp(char a[],char b[]){
return ( strcmp(a,b)> );
}
int main(){
char str[];
char *res[];
int i,cnt,l;
int RES;
int sign;
while(NULL!=gets(str)){
cnt=;
l=strlen(str); if( strcmp(str,"#")== ) break;
strcat(str," ");
sign=;
for(i=l-;i>=;--i){
if(sign==&&str[i]!=' '&&str[i+]==' '){
str[i+]='\0';
sign=;
}
if(sign==){
if(i==&&str[i]!=' '){
res[cnt]=&str[i];
sign=;
cnt++;
}
if(str[i]!=' ') continue;
if(str[i]==' '){
res[cnt]=&str[i+];
sign=;
cnt++;
}
} }
sort(res,res+cnt,cmp);
RES=;
RES=RES<cnt?RES:cnt;
for(i=;i<cnt;++i){
if( strcmp(res[i],res[i-])== ) continue;
else RES++;
} printf("%d\n",RES); }
return ; }
hdu2072的更多相关文章
- hdu2072 字典树
这题印象深刻,我刚接触acm时,以为这题是水题(因为是中文,又短),一直没做出.现再想想也是.可能也是我以前字符串掌握不好: 这题其实也可以用stl里的map写.这里我用字典树写的.其实这题算简单题了 ...
- hdu-2072(字典树)
字典树模板题 代码 #include<iostream> #include<algorithm> #include<cstdio> #include<cstr ...
- (set stringstream)单词数 hdu2072
单词数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- HDU2072 tri树/map/set/字符串hash
lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题 水题 就是用来试试字符串算法的 tri树 ...
- hdu2072 单词数 字典树
字典树裸题 #include<stdio.h> #include<string.h> ][]; ]; int cnt; int ans; void Insert(char *w ...
- HDU2072单词数
#include<iostream> #include<set> #include<sstream> using namespace std; int main() ...
- [HDU2072]单词数<字符串>
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 Problem Description lily的好朋友xiaoou333最近很空,他想了一件没有什 ...
- 单词数(hdu2072)
这道题用到了(STL初步)集合:Set 的知识点.同时,也用到了stringstream 的知识点,还用到了getline(cin,line)的知识点. #include<iostream> ...
- OJ题目分类
POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...
随机推荐
- [复变函数]第17堂课 5 解析函数的 Laurent 展式与孤立奇点 5. 1 解析函数的 Laurent 展式
0. 引言 (1) $f$ 在 $|z|<R$ 内解析 $\dps{\ra f(z)=\sum_{n=0}^\infty c_nz^n}$ (Taylor 级数). (2) $f$ 在 $ ...
- sql中实现split()功能
http://www.cnblogs.com/yangyy753/archive/2011/11/23/2260618.html 数据库中,总是遇到一些字段内容,想根据某个标识截取一下字符串,可是都想 ...
- andriod_入门一
[小技巧] 1.背景图片文件名不能以数字开头,必须以字母开头. 2.如果按钮被背景图被遮住,可以在relativelayout里拖动控件,把背景拖到最上方: [异常] 1. 在用LinearLayou ...
- silverlight 报 System.NullReferenceException 未将对象引用设置到对象的实例。
在 Microsoft.Windows.Design.Platform.SilverlightMetadataContext.SilverlightXamlExtensionImplementatio ...
- Laravel 5 IDE Helper 安装
一.项目地址 https://github.com/barryvdh/laravel-ide-helper 二.安装方法 1.方法一:直接使用已经生成的文件 下载 https://gist.githu ...
- 无状态服务(stateless service)
一.定义 无状态服务(stateless service)对单次请求的处理,不依赖其他请求,也就是说,处理一次请求所需的全部信息,要么都包含在这个请求里,要么可以从外部获取到(比如说数据库),服务器本 ...
- 玄机论坛Socket类库源码 当前版本 2.6.3 更新日期:10-09/2015 z
http://bbs.msdn5.com/thread-27-1-1.html 本类库采用TcpLister,TcpClient高度封装, 采用NetworkStream进行异步模式读取数据. 采用S ...
- 证书 pki
对称加密 symmetric cryptographic 非对称加密 asymmetric cryptographic 密钥交换协议 key agreement/exchang ...
- 读取缓存模拟----FIFO
本例是模拟缓存的存储和读取. 存储:使用一个Map来存放,key是文件名,值为缓存对象 读取:返回相应的key对应的缓存.(如果缓存被修改,就重新加载缓存,再从缓存Map中读取相应缓存) 测试类:每2 ...
- .Net中Math.Round与四舍五入
有不少人误将Math.Round函数当作四舍五入函数在处理, 结果往往不正确, 实际上Math.Round采用的是国际通行的是 Banker 舍入法. Banker's rounding(银行家舍入) ...