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 ...
随机推荐
- python(5)字符串处理 (sub,replace,find,index,upper,strip,split,sub翻页
一,sub和replace的用法 re.sub 函数进行以正则表达式为基础的替换工作 re.sub替换到目标字符串中的a,b或者c,并全部替换 另加上sub翻页操作: re.sub('start=\d ...
- image和字节流之间的相互转换
//将图片转化为长二进制 public Byte[] SetImgToByte(string imgPath) { FileStream file = new FileStream(imgPath, ...
- 发现木马C:\windows\system32\FastUserSwitchingCompatibilityex.dll
而且用安全狗还隔离不了
- ImageLoader_ _Universal-Image-Loader完全解析(一)之介绍与使用详解
转载请标明出处: http://blog.csdn.net/developer_jiangqq/article/details/50439814 本文出自:[江清清的博客] (一).前言: 已经半个月 ...
- Mac 10.10下安装MySQL5.6.21提示安装失败
只要要在安装的第三步在自定里不要选Startup item就可以了
- frame动画
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android=&q ...
- ubuntu14.04 wifi驱动安装
重装linux后,一直搜不到wlan0,无法启动wifi,经过重重努力,终于成功,在此简单记录一下. 1. 查看网卡类型: ~$ lspci -nn -d 14e4: :]: Broadcom Cor ...
- iOS使用AVFoundation实现二维码扫描
原文:http://strivingboy.github.io/blog/2014/11/08/scan-qrcode/ 关于二维码扫描有不少优秀第三方库如: ZBar SDK 里面有详细的文档,相应 ...
- [FlashPlyaer] FP版本20.0.267对Win10的64位系统的不兼容问题
Win10近日推送了一个新的升级补丁KB3132372,它专门用来修复Adobe Flash Player里的安全漏洞.但是很多用户反映升级了这个补丁之后导致浏览器上网时出现崩溃.卡死.空白等现象,尤 ...
- (整理).net实现条形码与二维码
本文由来源网络的知识点组合而成,感谢分享的作者,文章结尾处给出查询资料连接. 条形码(barcode)是将宽度不等的多个黑条和空白,按照一定的编码规则排列,用以表达一组信息的图形标识符.常见的条形码是 ...