树木品种-Qsort
来源:互联网 发布:郑州七中分校知乎 编辑:程序博客网 时间:2024/04/26 05:48
点击打开链接
为什么还会是Qsort,说明它很重要吧。
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<ctype.h>#include<signal.h>typedef struct s{ char str[32];}Str;Str c[101000];int counts[101000];int times = 1;int cmp(const void *a,const void *b){ Str *f1 = (Str*)a; Str *f2 = (Str*)b; return strcmp(f1->str,f2->str);}int main(){ int n,m; int i=0; int num; char s[32]; while(gets(s)){ strcpy(c[i++].str,s); } n = i; qsort(c,n,sizeof(c[0]),cmp); i = 1; num = 1; while(i<n){ if(strcmp(c[i].str,c[i-1].str)!=0){ printf("%s %.4lf\n",c[i-1].str,(double)100*num/n); num = 1; } else num ++; i++; } printf("%s %.4lf\n",c[i-1].str,(double)100*num/n); return 0;}
0 0
- 树木品种-Qsort
- QSORT
- qsort
- QSort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- qsort
- java中Date类的练习
- ios学习之universal
- Hadoop集群环境搭建(win7下vmware虚拟ubuntu)
- hdu 大菲波数
- Python 的join函数
- 树木品种-Qsort
- UITableView的基本使用三(自定义Cell)
- python操作MySQL数据库
- <<Oracle数据库性能优化艺术(第五期)>> 第15周 基于Oracle RAC架构的性能优化
- singleton
- 模态对话框和非模态对话框
- [Leetcode] Word Break (Java)
- 【序一】由nodejs+mongodb开发的ideas小站
- 照片Urls