自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 Random_Select

#include "stdafx.h"int PARTITION(int a[], int p, int r) //以递增顺序排序{ int x = a[r]; int i = p - 1; for (int j = p; j < r; ++j) { if (a[j]

2015-11-18 14:49:19 1004

原创 Random_QuickSort

#include "stdafx.h"int PARTITION(int a[], int p, int r) //以递增顺序排序{ int x = a[r]; int i = p - 1; for (int j = p; j < r; ++j) { if (a[j]

2015-11-18 10:49:16 451

原创 同时得到最大最小值的最优算法

首先,我们将一对输入元素进行比较,然后把较小的值与最小值比较,较大值与最大值比较。这样,每两个元素共需3次比较。如果n是奇数,就把最大最小值的初值都设为第一个元素的值,然后成对处理剩下的元素;如果n是偶数,则先比较前两个元素,决定最大最小值的初值,然后成对处理剩下的元素。#include "stdafx.h"struct Max_Min{public: int max; i

2015-11-18 08:51:18 3228

原创 c++primer第十章习题(2)

10.11 写一个程序,用stable_sort和isshorter来排列一个传递到你自己版本elimdups的vector。#include "stdafx.h"bool isShorter(const string &s1, const string &s2){ return s1.size() < s2.size();}int _tmain(int argc, _TCHA

2015-11-15 19:59:13 272

原创 c++primer第十章习题(1)

10.1 用count,计算某个整数在vector中出现次数。 解:#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ int val = 42; vector<int> a = { 1, 2, 42, 5, 76, 42, 34, 42, 987, 42, 56, 34 }; auto re

2015-11-14 18:58:12 234

原创 快速排序

1.以递增顺序排序#include "stdafx.h"int PARTITION(int a[], int p, int r) //以递增顺序排序{ int x = a[r]; int i = p - 1; for (int j = p; j < r;++j) {

2015-11-14 18:12:01 232

原创 最小堆

#include "stdafx.h"void MIN_HEAPIFY(int a[], int i,int len){ int l = 2 * i + 1, r = 2 * i + 2; int smallest = i; //预设该节点为最大 if (l <= len &&a[l]

2015-11-14 18:10:42 274

原创 最大堆

#include "stdafx.h"void MAX_HEAPIFY(int a[], int i,int len){ int l = 2 * i+1, r = 2 * i + 2; int largest = i; //预设该节点为最大 if (l<=len &&a[l]>a[i])

2015-11-14 18:10:12 222

原创 堆排序

#include "stdafx.h"void MAX_HEAPIFY(int a[], int i, int len){ int l = 2 * i + 1, r = 2 * i + 2; int largest = i; //预设该节点为最大 if (l <= len &&a[l]

2015-11-14 18:09:28 210

原创 最大子数组

#include "stdafx.h"struct result{public: int left, right, sum;};struct result Find_Max_Crossing_Subarray(int a[],int low,int mid,int high){ result cross; int left_sum = -1000,right_sum

2015-11-14 18:08:33 238

原创 变长数据项排序

a.// Al_8-3_a.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"struct bucket{ double value; bucket *next;};bucket *buckets[100];bucket *insert(bucket *head, double m){ bucket *p0, *p1, *p2;

2015-11-14 18:04:14 365

原创 桶排序

// Bucket_Sort.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"struct bucket{ double value; bucket *next;};bucket *buckets[100];bucket *insert(bucket *head, double m){ bucket *p0, *p1, *p2;

2015-11-14 18:02:46 215

原创 基数排序

#include "stdafx.h"void Counting_Sort(int a[], int b[], int k, int len){ int c[100] = { 0 }, temp[100] = { 0 }; for (int j = 0; j < len; ++j) //统计等于i的个数 {

2015-11-14 18:02:16 210

原创 计数排序

#include "stdafx.h"void Counting_Sort(int a[], int b[], int k,int len){ int c[100]; for (int i = 0; i < k+1; ++i) { c[i] = 0; } for (int j = 0; j < len; ++j)

2015-11-14 18:01:34 205

原创 贺利坚练习(7)

【项目1-折腾二维数组】 创建一个5行4列的二维整型数组,通过初始化,为数组中的前两列的10个元素赋初值,然后:通过键盘输入,使后两列的10个元素获得值;按行序优先输出数组元素;将所有元素值乘以3后保存在数组中;按列序优先输出(输出的第一行是数组中的第一列……,其实输出的就是“转置”);将数组“倒”着输出(即最后一行最后一列的最先输出,第0行第0列的最后输出);输出数组中的所有偶数;输

2015-11-10 16:38:44 472

原创 贺利坚练习(6)

A: 数组逆序输出 Description 输入10个整数存入一维数组,然后按逆序输出。 Input 输入包括一行。 10个以空格隔开的整数。 Output 逆序的10个整数,整数以空格隔开。 Sample Input 1 3 5 9 7 6 8 2 4 0 Sample Output 0 4 2 8 6 7 9 5 3 1 解:int _tmain(int argc, _

2015-11-08 11:13:33 396

转载 git在本地仓库直接使用rm彻底删除文件,服务端还是存在。(已解决)

原文地址:http://www.pizida.com/git-rm.html本地仓库:A和B服务器:C今天在本地仓库A希望删除一个文件test,于是执行以下命令:1234$ sudo rm test$ git add .$ git commit -m "delete test"$ git push origin

2015-11-05 22:15:31 6167

原创 c++primer第九章习题(5)

9.47 写一个程序,找出string“ab2c3d7R4E6”中的数字和字母。 解:int _tmain(int argc, _TCHAR* argv[]){ string str1 = { "ab2c3d7r4e6" }; string str2 = { "0123456789" }; vector<char> res1, res2; str

2015-11-05 19:02:29 251

原创 c++primer第九章习题(4)

9.27 写一个程序,找到并移除forward_list中的奇数。 解:int _tmain(int argc, _TCHAR* argv[]){ forward_listint> list1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; auto prev = list1.before_begin(); auto curr =

2015-11-05 10:11:07 258

原创 c++primer第九章习题(3)

9.18 写一个程序从输入添加字符串到deque中,并用迭代器写一个循环输出deque中的元素。 解:这里写代码片

2015-11-04 18:50:57 228

原创 c++primer第九章习题(2)

9.14 写一个程序,将char*指向的字符构成的list赋值给string的vector。int _tmain(int argc, _TCHAR* argv[]){ list<char *> strings = { "he","ha", "oo" }; vector<string> strings2; strings2.assign(strings.begin(

2015-11-02 18:43:47 228

原创 修改归并排序实现逆序对计数

若i<j,且A[i]>A[j],则对偶(i,j)称为A的一个逆序对。#include "stdafx.h"void MERGE(int a[], int p, int q, int r,int &count) //p,q,r皆为数组元素序号{ //static int temp1 = q - p + 1; int temp2 = r - q; //将

2015-11-02 17:47:52 705

原创 冒泡法排序

#include "stdafx.h"void Bubble_Sort(int a[],int len){ //int len = sizeof(a) / 4; for (int i = 0; i < len;++i) { for (int j = len-1; j > i;--j) { if (a[j]<a[j-1]

2015-11-02 17:45:00 285

原创 二分查找

#include "stdafx.h"int Binary_Sort(int a[], int i, int j, int value){ if (i<=j) { int mid = (i + j) / 2; if (value <a[mid]) { Binary_Sort(a, i, mid - 1, val

2015-11-02 17:44:27 220

原创 归并排序

#include "stdafx.h"void MERGE(int a[], int p, int q, int r) //p,q,r皆为数组元素序号{ int temp1 = q - p+1; int temp2 = r - q; //将拆分的两部分数组分别存入新的数组 int *bArray; int *cArray; bArray

2015-11-02 17:42:54 214

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除