随笔分类 - 排序
摘要:2016: Sort the StudentsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K1417539StandardGiven the class numbers and the scores of a group of students, you are to write a program to sort the students first by class number in ascending order and then by score in descending order.InputThe input
阅读全文
摘要:一、对int类型数组排序int num[100];Sample:int cmp ( const void *a , const void *b ){return *(int *)a - *(int *)b;}qsort(num,100,sizeof(num[0]),cmp);二、对char类型数组排序(同int类型)char word[100];Sample:int cmp( const void *a , const void *b ){return *(char *)a - *(int *)b;}qsort(word,100,sizeof(word[0]),cmp);三、对double类型
阅读全文
摘要:快速排序是对冒泡排序的改进,主要思想是通过一次排序将序列分成两部分,左边的部分全部小于基准值,右边的部分大于基准值。在这一思想下,有不同的几种实现方式。(以下代码中的测试数据来自用系统时间做种的随机生成序列)(除了以下版本,还有一些其他的快排的想法。)1. 比较好理解的版本 1 /* 2 *2012年2月13日11:28:00 3 *quickSort 4 *这个版本是比较好理解的版本(效率不是最高的) 5 *quickSort函数第二个参数是要排序的数组起始下标,第三个参数是结束下标 6 *过程: 7 *1. 将最左边的数设为val(也即关键字) 8 *2. 从i开始向右找...
阅读全文

浙公网安备 33010602011771号