# SDUT യ data structure experiment search 3: tree species statistics

Posted by makeshift_theory on Fri, 03 Jan 2020 12:07:52 +0100

### Data structure experiment search 3: tree species statistics

Time Limit: 400 ms Memory Limit: 65536 KiB

Problem Description

With the application of satellite imaging technology, natural resource research institutions can identify the type of each tree. Please write a program to help researchers count the number of each tree and calculate the percentage of each tree in the total.

Input

Enter a set of test data. The first line of the data gives a positive integer N (N < = 100000), N represents the number of trees; then N lines, each line gives the type name of a tree observed by the satellite. The name of the tree is a string of no more than 20 characters. The string consists of English letters and spaces, regardless of case.

Output

Output all kinds of tree names and their percentages in dictionary order, with spaces in the middle and two decimal places after the decimal point.

Sample Input

```2
This is an Appletree
this is an appletree```

Sample Output

`this is an appletree 100.00%`

Hint

Source

xam

Binary sort tree

```#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node
{
char str[22];
int cnt;
struct node *left;
struct node *right;
};

int n;

struct node *creat(struct node *head, char *s)
{
{
head = (struct node *)malloc(sizeof(struct node));
}
else
{
int k;
k = strcmp(head -> str, s);
if(k > 0)
{
}
else if(k < 0)
else
}
};

{
{
printf("%s %.2lf%c\n", head -> str, head -> cnt * 100.0 / n, '%');
}
}

int main()
{
char s[22];
scanf("%d", &n);
getchar();                              //Line feed
int i, j;
for(i = 0; i < n; i++)
{
gets(s);
for(j = 0; s[j]; j++)
{
if(s[j] >= 'A' && s[j] <= 'Z')  // All changed to lowercase
s[j] += 32;
}
}
return 0;
}
```