数据结构实验之查找三:树的种类统计

Time Limit: 400MS Memory Limit: 65536KB

Problem Description

随着卫星成像技术的应用,自然资源研究机构可以识别每一个棵树的种类。请编写程序帮助研究人员统计每种树的数量,计算每种树占总数的百分比。

Input

输入一组测试数据。数据的第1行给出一个正整数N (n <= 100000),N表示树的数量;随后N行,每行给出卫星观测到的一棵树的种类名称,树的名称是一个不超过20个字符的字符串,字符串由英文字母和空格组成,不区分大小写。

Output

按字典序输出各种树的种类名称和它占的百分比,中间以空格间隔,小数点后保留两位小数。

Example Input

2
This is an Appletree
this is an appletree

Example Output

this is an appletree 100.00%

DQE:

 
二叉排序树的应用,全转换为小写就AAAC了233
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; struct Tree
{
char name[];
int n;
Tree *lt,*rt;
}; void insert(Tree *&root,char *e)
{
if(!root)
{
Tree *r=new Tree;
strcpy(r->name,e);
r->n=;
r->lt=r->rt=NULL;
root=r;
}
else
{
int cmp=strcmp(e,root->name);
if(cmp<)
insert(root->lt,e);
else if(cmp>)
insert(root->rt,e);
else
root->n++;
}
} int n;
void mout(Tree *root)
{
if(root)
{
mout(root->lt);
printf("%s %.2f%%\n",root->name,root->n*100.0/n);
mout(root->rt);
}
} int main()
{
int t;
scanf("%d\n",&t);
n=t;
Tree *root=NULL;
while(t--)
{
char ch,e[];
int i=;
while(ch=getchar(),ch!='\n')
{
if(ch>='A'&&ch<='Z')
e[i]=ch+;
else
e[i]=ch;
i++;
}
e[i]='\0';
insert(root,e);
}
mout(root);
return ;
} /***************************************************
User name: ***
Result: Accepted
Take time: 0ms
Take Memory: 156KB
Submit time: 2016-11-29 17:54:17
****************************************************/

SDUT 3375 数据结构实验之查找三:树的种类统计的更多相关文章

  1. SDUT-3375_数据结构实验之查找三:树的种类统计

    数据结构实验之查找三:树的种类统计 Time Limit: 400 ms Memory Limit: 65536 KiB Problem Description 随着卫星成像技术的应用,自然资源研究机 ...

  2. SDUT 3374 数据结构实验之查找二:平衡二叉树

    数据结构实验之查找二:平衡二叉树 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 根据给定的输 ...

  3. SDUT 3311 数据结构实验之串三:KMP应用

    数据结构实验之串三:KMP应用 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 有n个小朋友 ...

  4. SDUT 3347 数据结构实验之数组三:快速转置

    数据结构实验之数组三:快速转置 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 转置运算是一 ...

  5. SDUT OJ 数据结构实验之二叉树三:统计叶子数

    数据结构实验之二叉树三:统计叶子数 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...

  6. SDUT OJ 数据结构实验之串三:KMP应用

    数据结构实验之串三:KMP应用 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...

  7. SDUT OJ 数据结构实验之排序三:bucket sort

    数据结构实验之排序三:bucket sort Time Limit: 250 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem D ...

  8. SDUT OJ 数据结构实验之链表三:链表的逆置

    数据结构实验之链表三:链表的逆置 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descri ...

  9. SDUT 3400 数据结构实验之排序三:bucket sort

    数据结构实验之排序三:bucket sort Time Limit: 150MS Memory Limit: 65536KB Submit Statistic Problem Description ...

随机推荐

  1. Unity项目UI图片压缩格式(UGUI)

    http://blog.csdn.net/bobodan123/article/details/70316538 UI制作时候使用的是Ps 8位 RGB通道的色彩. 但导出的是16位RGBA色彩的图片 ...

  2. 谈谈Linux内核驱动的coding style

    最近在向Linux内核提交一些驱动程序,在提交的过程中,发现自己的代码离Linux内核的coding style要求还是差很多.当初自己对内核文档里的CodingStyle一文只是粗略的浏览,真正写代 ...

  3. es6字符串的扩展学习笔记

    1. 传统上,JavaScript只有indexOf方法,可以用来确定一个字符串是否包含在另一个字符串中.ES6又提供了三种新方法. includes():返回布尔值,表示是否找到了参数字符串. st ...

  4. 使用PowerShell在Azure China创建Data Warehouse

    微软的Azure Data Warehouse是基于MPP架构的分布式系统: Control Node负责管理系统和接受用户的请求,Compute Node负责计算. 目前在国内Azure Data ...

  5. HDU1021(模运算)

    Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. 西安电子科技大学第16届程序设计竞赛 F Operating System (unique() 去重函数)

    链接:https://www.nowcoder.com/acm/contest/107/F来源:牛客网 Operating System 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ ...

  7. 2018年长沙理工大学第十三届程序设计竞赛 Dzzq的离散数学教室1

    Dzzq的离散数学教室1 链接:https://www.nowcoder.com/acm/contest/96/D来源:牛客网 zzq的离散数学教室1 时间限制:C/C++ 1秒,其他语言2秒 空间限 ...

  8. Java-API:java.util.UUID

    ylbtech-Java-API:java.util.UUID 1.返回顶部   2.返回顶部   3.返回顶部   4. 百科返回顶部   5.返回顶部 0. https://docs.oracle ...

  9. 我和domino不得不说的故事(连载2016-3-2)

    1.关于NotesViewEntry 注意:通过NotesViewEntry获取某列的值时,若该列的值为@IsExpandable or @DocNumber 或者是常量时,将不会显示. Set en ...

  10. maven学习6 Eclipse下Tomcat常用设置

    Eclipse下Tomcat常用设置 1,Eclipse建立Tomcat服务 1.1 新建Server 首先这里是指,jee版的Eclipse.Eclipse是没有像MyEclipse那样集成Tomc ...