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

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. POJ - 3150 :Cellular Automaton(特殊的矩阵,降维优化)

    A cellular automaton is a collection of cells on a grid of specified shape that evolves through a nu ...

  2. Git学习原版手稿

    手稿诞生记        Git学习的时候难免会有遗忘然后往复学习查看的过程,所以就形成了这个学习的手稿,记录了Git使用过程中的大部分命令,今天在清理的时候偶然看到了这些记录,而且最近也在写Git的 ...

  3. 利用MsChart控件绘制多曲线图表

    在.Net4.0框架中,微软已经将Mschart控件集成了进来,以前一直在web下面用过,原来winform下的Mschart控件更加简单更加方便,今天我们用mschart绘制一个多曲线图,发现MsC ...

  4. (C#)把磁盘目录树加载在窗体菜单中

    这又是一个没有技术含量的代码.写出来只是玩玩,所以也不敢放在首页. 这里有个问题,是获取文件/文件夹的图标.使用 System.Drawing.Icon.ExtractAssociatedIcon 只 ...

  5. bzoj 2839 集合计数 —— 二项式反演

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2839 设 \( f(i) \) 为至少 \( i \) 个选择,则 \( f(i) = C_ ...

  6. JavaScript正则常用知识总结

    一.JavaScript正则相关方法 str.match(regexp)与regexp.exec(str)功能类似. str.search(regexp)与regexp.test(str)功能类似. ...

  7. java继承初级

    总结:重写方法,方法体内容不同. 还有子类都不能加public.它表示公共,一个程序只能有一个公共类 package com.sa; public class Ac { public void rea ...

  8. 【OK210试用体验】进阶篇(1)视频图像采集之MJPG-streamer编译(Ubuntu系统下)

    转自: http://bbs.elecfans.com/jishu_510084_1_1.html 本篇主要内容分为: 嵌入式视频图像开源库     mjpg-streamer简介     mjpg- ...

  9. Rails中文乱码问题【转】

    乱码情况一:netbeas控制台输出乱码 具体表现为:在程序中定义中文字符串,然后输出.但输出为乱码 解决方法:打开netbeans安装目录,找到etc目录下的netbeans.conf文件.在net ...

  10. 2015.4.21 SetWindowPos函数用法

    定义:[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, int hWndl ...