注意输入全是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的更多相关文章

  1. hdu2072 字典树

    这题印象深刻,我刚接触acm时,以为这题是水题(因为是中文,又短),一直没做出.现再想想也是.可能也是我以前字符串掌握不好: 这题其实也可以用stl里的map写.这里我用字典树写的.其实这题算简单题了 ...

  2. hdu-2072(字典树)

    字典树模板题 代码 #include<iostream> #include<algorithm> #include<cstdio> #include<cstr ...

  3. (set stringstream)单词数 hdu2072

    单词数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  4. HDU2072 tri树/map/set/字符串hash

    lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题 水题 就是用来试试字符串算法的 tri树 ...

  5. hdu2072 单词数 字典树

    字典树裸题 #include<stdio.h> #include<string.h> ][]; ]; int cnt; int ans; void Insert(char *w ...

  6. HDU2072单词数

    #include<iostream> #include<set> #include<sstream> using namespace std; int main() ...

  7. [HDU2072]单词数<字符串>

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 Problem Description lily的好朋友xiaoou333最近很空,他想了一件没有什 ...

  8. 单词数(hdu2072)

    这道题用到了(STL初步)集合:Set 的知识点.同时,也用到了stringstream 的知识点,还用到了getline(cin,line)的知识点. #include<iostream> ...

  9. OJ题目分类

    POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...

随机推荐

  1. c语言知识(2)

    while(n)首先,n在这里被当作了一个条件其次,当n为真时,进入while循环体(A):否则跳出循环继续执行下面部分(B).n为0时条件为假  n不为0条件为真 while(j) { if(j%1 ...

  2. NoSQL与关系型数据库比较

    虽然09年出现了比较激进的文章<关系数据库已死>,但是我们心里都清楚,关系数据库其实还活得好好的,你还不能不用关系数据库.但是也说明了一个事实,关系数据库在处理WEB2.0数据的时候,的确 ...

  3. R %operator% 含义

    %foo% is the syntax for a binary operator. In base R: %in%: '"%in%" <- function(x, tabl ...

  4. FOOD

    Serving order of food courses(上菜顺序)1. Appetizer(starter)2. Main Course3. Dessert Style of cooking1. ...

  5. ruby中迭代器枚举器的理解

    参考<ruby编程语言>5.3迭代器和可枚举对象 迭代器一个迭代器是一个方法,这个方法里面有yield语句,这个方法里的yield语句,与传递给这个方法的块进行数据传输 yield将数据传 ...

  6. Liferay中SQL打印参数

      XX\tomcat-7.0.42\webapps\ROOT\WEB-INF\classes\log4j.properties log4j.rootLogger=INFO, CONSOLE log4 ...

  7. 基于lucene实现自己的推荐引擎

    基于lucene实现自己的推荐引擎 推荐常用算法之-基于内容的推荐 推荐算法

  8. 荣耀6 Plus 的屏幕大小pt计算方法

    使用 gomobile 检测 华为荣耀 6 Plus 的屏幕大小为:  1080*1776 px ;   162pt*266.40pt ;  每pt像素个数:6.666665个. 而实际的数据是: 主 ...

  9. Python的安装与基本语法

    一,Python简介      Python是一种计算机程序设计语言,都是使用C语言实现,但是比C语言容易学习,易于阅读.Python可以应用于众多领域,整体呈上升趋势,广泛使用Python来做的事一 ...

  10. (*medium)LeetCode 211.Add and Search Word - Data structure design

    Design a data structure that supports the following two operations: void addWord(word) bool search(w ...