/*
*@Category 数组冒泡排序类
*@param array_arsort 类中操作方法
*@author yalong sun
*/
//从大到小排序
class array_maopao{
public function array_arsort($array){
$ary = '';
for($j...
分类:
其他好文 时间:
2014-07-31 13:34:56
阅读次数:
176
#region 数组 最大值 最小值 平均值 求和 冒泡排序 int[] arrag = new int[5] { 31, 62, 83, 54, 85 }; for (int i = 0; i arrag[j]) { int myarrag; myarrag = arrag[i]; a...
分类:
其他好文 时间:
2014-07-31 09:44:06
阅读次数:
181
#import<Foundation/Foundation.h>
typedefstruct
{
charname[20];
intage;
floatscore;
}Stu;
//建立字符串和函数之间的一一对应关系.
typedefBOOL(*PStu)(Stustu1,Stustu2);
typedefstructnameFunctionPair{
charname[20];//存储函数对应的字符串
PStufunction;//存储..
分类:
其他好文 时间:
2014-07-31 03:11:26
阅读次数:
154
1.冒泡排序,时间复杂度O(n^2)void bubble_sort(int arr[], int num) { int i,j,t; for(j=0;j<num-1;j++) //共进行num-1趟比较 for(i=0;i<num-j-1;i++) ...
分类:
其他好文 时间:
2014-07-31 02:35:45
阅读次数:
186
typedefstruct
{
charname[20];
intage;
floatscore;
}Stu;
#import<Foundation/Foundation.h>
//姓名升序
voidsortByName(Stu*p,intcount)
{
for(inti=0;i<count-1;i++){
for(intj=0;j<count-1-i;j++){
if(strcmp((p+j)->name,(p+j+1)->name)>0){
Stute..
分类:
其他好文 时间:
2014-07-30 17:51:35
阅读次数:
207
题目大意:众所周知冒泡排序算法多数情况下不能只扫描一遍就结束排序,而是要扫描好几遍。现在你的任务是求1~N的排列中,需要扫描K遍才能排好序的数列的个数模20100713。注意,不同于真正的冒泡排序算法,只要数列有序就立刻停止,而不用再检验一遍。估计多数人都是找规律吧,先看出递推,然后求出通项……这个...
分类:
其他好文 时间:
2014-07-29 10:40:06
阅读次数:
270
废话不多说直接开始第三种武功:交换排序 交换排序分为两类,冒泡排序(BubbleSort)和快速排序(QuickSort)。一、算法实现思想; BubbleSort算法实现思想: 两两比较相邻记录的关键码,如果反序则交换。直到所有记录顺序为止。 QuickSort算法实现思想: ...
分类:
其他好文 时间:
2014-07-27 21:31:05
阅读次数:
189
#includevoid BubbleSort(int n,int a[]){ for(int i=0;ia[j+1]) { int tmp=a[j]; a[j]=a[j+1]; a...
分类:
其他好文 时间:
2014-07-26 13:49:14
阅读次数:
175
快速排序(Quicksort) 是对冒泡排序的一种改进,它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行,以此达到整个数据变成有序序列。 设要排序的数组是A...
分类:
移动开发 时间:
2014-07-24 22:28:52
阅读次数:
213