数据结构实验之查找三:树的种类统计(SDUT 3375)
C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
char data[30];
struct node *lc;
struct node *rc;
int num;
};
char a[30];
int n;
struct node *creat(struct node *root)
{
if(root == NULL)
{
root = (struct node *)malloc(sizeof(struct node));
root->lc = NULL;
root->rc = NULL;
root->num = 1;
strcpy(root->data, a);
}
else
{
if(strcmp(a, root->data) == 0)
{
root->num++;
}
else if(strcmp(a, root->data) < 0)
{
root->lc = creat(root->lc);
}
else
{
root->rc = creat(root->rc);
}
}
return root;
};
void fin(struct node *root)
{
if(root != NULL)
{
fin(root->lc);
printf("%s %.2lf%%\n", root->data, 1.0 * root->num * 100 / n);
fin(root->rc);
}
}
int main()
{
int i, j;
int len;
struct node *root;
scanf("%d ", &n);
root = NULL;
for(i = 0; i < n; i++)
{
gets(a);
len = strlen(a);
for(j = 0; j < len; j++)
{
if(a[j] >= 'A' && a[j] <= 'Z')
{
a[j] = a[j] + 32;
}
}
root = creat(root);
}
fin(root);
return 0;
}
数据结构实验之查找三:树的种类统计(SDUT 3375)的更多相关文章
- SDUT 3375 数据结构实验之查找三:树的种类统计
数据结构实验之查找三:树的种类统计 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 随着卫星成 ...
- SDUT-3375_数据结构实验之查找三:树的种类统计
数据结构实验之查找三:树的种类统计 Time Limit: 400 ms Memory Limit: 65536 KiB Problem Description 随着卫星成像技术的应用,自然资源研究机 ...
- 数据结构实验之图论三:判断可达性(SDUT 2138)(简单DFS)
#include <bits/stdc++.h> using namespace std; int gra[1002][1005]; int vis[1002]; int n,m; voi ...
- SDUT 3374 数据结构实验之查找二:平衡二叉树
数据结构实验之查找二:平衡二叉树 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 根据给定的输 ...
- SDUT-3373_数据结构实验之查找一:二叉排序树
数据结构实验之查找一:二叉排序树 Time Limit: 400 ms Memory Limit: 65536 KiB 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 ...
随机推荐
- CentOS 7忘记了root密码解决方案
1.启动系统,在选择进入系统的界面按“e”进入编辑页面 2.按向下键,找到以“Linux16”开头的行,在该行的最后面输入“init=/bin/sh” 3.按“ctrl+X”组合键进入单用户模式 4 ...
- PHP Math函数
abs() 绝对值. acos() 反余弦. acosh() 反双曲余弦. asin() 反正弦. asinh() 反双曲正弦. atan() 反正切. atan2() 两个参 ...
- 什么是RAID(磁盘阵列)
RAID全称Redundant Array of Independent Disk,即独立冗余磁盘阵列.RAID技术由加州大学伯克利分校1987年提出,最初是为了组合小的廉价磁盘来代替大的昂贵磁盘,同 ...
- ajax提交异常解决
一.遇到的问题 在项目中使用ajax提交表单失败,并且后台程序都没有执行,分析具体问题是由于post表单时contenttype的类型不一致. 二.解决方式 $.ajax({ type: 'post' ...
- SMARTY的知识
smarty的原理: <?php class Smarty { $ldelimiter = "{";//左分隔符 $rdelimiter = "}";// ...
- 攻防世界(Ctf-Web 新手练习区 Writeup)
平台地址:adworld.xctf.org.cn 在打着暑假工赚零花钱之余,我将这些题利用空余时间刷了一遍,感觉内心还是比较满足的! 题目:view_source 这道题没啥好说的,在url的前面加上 ...
- Jlink调试S5PV210
安装CDT C/C++ Development Toolkit,使eclipse可以开发C/C++项目 Help–>Install New Software中输入:http://download ...
- MySQL主从复制(Centos6.3&MySQL5.6)
环境: Master:Centos 6.3 192.168.1.4 Slave:Centos 6.3 192.168.1.5 MySQL: MySQL-5.6.2 ...
- Python 渗透测试编程技术方法与实践 ------全书整理
1.整个渗透测试的工作阶段 ( 1 )前期与客户的交流阶段.( 2 )情报的收集阶段.( 3 )威胁建模阶段.( 4 )漏洞分析阶段.( 5 )漏洞利用阶段.( 6 )后渗透攻击阶段.( 7 )报告阶 ...
- 检查shell脚本
1.检查solr服务监控脚本: #/bin/bash starttime=$(date +%Y-%m-%d\ %H:%M:%S) http_code=$(curl -I -m -o /dev//sol ...