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 ...
随机推荐
- redis使用日志(二) 数据存储到redis
一段简短的代码,来展示如何把爬取内容写到redis里面: #! /usr/bin/env python # -*- coding=utf-8 -*- import requests import js ...
- Git Step by Step
原文地址:http://www.cnblogs.com/wilber2013/category/643754.html 1.Git简介 2.Git本地仓库 3.Git对象模型 4.探索.git目录 5 ...
- 【JavaScript】微信适配的Head
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <me ...
- Mac 终端常用命令备忘
Tab 补全 pwd 显示路径 一 .ls ls -lh 查看当前路径详细文件 ls .. 返回上级目录 ls -a 显示隐藏文件 ls -a -l 以详细列表显示 ls ../../ ...
- bat命令之for命令详解
______________版主提醒____________________________ 为了避免影响技术讨论.提高看帖的舒适性,请大家不要在此帖下跟无实质内容的口水帖,特别是纯顶.纯支持.纯感谢 ...
- WPF NotifyIcon and Taskbar 任务栏示例
Demo Source 转自:http://www.codeproject.com/Articles/36788/WPF-XAML-NotifyIcon-and-Taskbar-System-Tray ...
- Zabbix监控mysql配置及故障告警配置
本文主要介绍zabbix监控mysql的配置,包含使用zabbix自带模板监控mysql相关信息及自定义key监控mysql同步情况.同时介绍了触发器的创建及zabbix通过邮件方式告警配置. 一.配 ...
- java io操作常规
1.四种类型: 字节流: InputStream OutputStream 字符流: Reader Writer 2.转换流 InputStreamReader, OutPutStreamWriter ...
- java异常处理机制throws
throws可以在方法声明时抛出的异常.原则上throws声明的异常,一定要在该方法中抛出,否则没有意义. 相反的,若方法中我们主动通过throw抛出一个异常,应该在throws中声明该种类异常,通知 ...
- LeetCode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...