摘要: 分治法的思想:将原问题分解为几个规模较小但类似于原问题的子问题,递归地求解这些子问题,然后再合并这些子问题的解来建立原问题的解。 1 2 #include "stdafx.h" 3 #include 4 using namespace std; 5 6 void Merge(int *arr,int p ,int q ,int r);//归并排序 7 8 void mergesort(int *arr,int p,int r); 9 void ViewData(int *,int len);10 int _tmain(int argc, _TCHAR* argv[])11 阅读全文
posted @ 2013-10-06 00:54 CrazyCode. 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 插入排序:对于少量元素的排序,是一个比较有效的算法。#include "stdafx.h"#includeusing namespace std;void Insertion_Sort(int *,int );//插入升序排序void Insertion_SortDown(int *,int );//插入降序排序void ViewData(int *,int len);//读数据int _tmain(int argc, _TCHAR* argv[]){int arr[]={5,2,12,34,2,4,6,1,3};size_t len=sizeof(arr)/sizeof( 阅读全文
posted @ 2013-10-06 00:49 CrazyCode. 阅读(144) 评论(0) 推荐(0) 编辑