SDUT 3375 数据结构实验之查找三:树的种类统计
数据结构实验之查找三:树的种类统计
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:
#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 数据结构实验之查找三:树的种类统计的更多相关文章
- SDUT-3375_数据结构实验之查找三:树的种类统计
数据结构实验之查找三:树的种类统计 Time Limit: 400 ms Memory Limit: 65536 KiB Problem Description 随着卫星成像技术的应用,自然资源研究机 ...
- SDUT 3374 数据结构实验之查找二:平衡二叉树
数据结构实验之查找二:平衡二叉树 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 根据给定的输 ...
- SDUT 3311 数据结构实验之串三:KMP应用
数据结构实验之串三:KMP应用 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 有n个小朋友 ...
- SDUT 3347 数据结构实验之数组三:快速转置
数据结构实验之数组三:快速转置 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 转置运算是一 ...
- SDUT OJ 数据结构实验之二叉树三:统计叶子数
数据结构实验之二叉树三:统计叶子数 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...
- SDUT OJ 数据结构实验之串三:KMP应用
数据结构实验之串三:KMP应用 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT OJ 数据结构实验之排序三:bucket sort
数据结构实验之排序三:bucket sort Time Limit: 250 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem D ...
- SDUT OJ 数据结构实验之链表三:链表的逆置
数据结构实验之链表三:链表的逆置 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descri ...
- SDUT 3400 数据结构实验之排序三:bucket sort
数据结构实验之排序三:bucket sort Time Limit: 150MS Memory Limit: 65536KB Submit Statistic Problem Description ...
随机推荐
- Object 的一个问题
var s1 = 'abc'; s1 instanceof String //false var s2 = new String('abc'); s2 instanceof Strin ...
- WC2019 滚粗记
离开的时候一定是笑着离开的 不然就再也回不来了 广州二中,七月再见
- Windbg内核调试之一: Vista Boot Config设置
Windbg进行内核调试,需要一些基本的技巧和设置,在这个系列文章中,我将使用Windbg过程中所遇到的一些问题和经验记录下来,算是对Kernel调试的一个总结,同时也是学习Windows系统内核的另 ...
- Visualforce入门第二篇_2017.3.1
代码实现类似Html的表单(Form) <apex:page sidebar="false" standardController="Account"&g ...
- Python 函数之lambda、map、filter和reduce
1.lambda函数 lambda()是Python里的匿名函数,其语法如下: lambda [arg1[, arg2, ... argN]]: expression 学习条件运算时,对于简单的 if ...
- 添加gitolite用户和仓库
1.在linux工作机上生成密钥对 ssh-keygen -t rsa 输入用户名但不输入passphrase,这样连接时就不用每次都输入passphrase了. 2.添加用户和仓库 在管理员的工作机 ...
- 四、ABP 学习系列 - 配置Swagger
一.再XX.Web项目中用Nuget安装Swashbuckle.AspNetCore.SwaggerGen和Swashbuckle.AspNetCore.SwaggerUI 二.在Startup.cs ...
- (转)AppCan中调用系统浏览器打开网页
<!DOCTYPE html> <html> <head> <style>body{ background:#fff; font-size:30px;} ...
- the virtual machine is configured for 64-bit guest operating systems
Security--Virtualization--Inter(R) Virtualization Technolog 设置为enable 本机安装的是WIN 7 ,详细版本是:Windows 7 U ...
- Mybatis 一对一(OneToOne)关系映射__INSERT
今天测试Ibatis的一对一的关联映射时总是出现错误,其中很多的错误都是自己不小心写错的..现把整个Ibatis源代码记录下来,以便以后熟记: 1.数据库脚本: CREATE TABLE t_pers ...