自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【归并排序】C++实现归并排序代码

#include<iostream>using namespace std;void merge(int a[], int start, int mid, int end){ int *tmp = (int *)malloc((end-start+1)*sizeof(int)); int i = start; int j = mid + 1; ...

2018-09-04 10:46:20 1653 1

原创 C++实现两个有序数组的合并

#include<iostream>using namespace std;int *SortArry(int *StrA,int lenA, int *StrB, int lenB){ if (StrA == NULL || StrB == NULL) return NULL; int *StrC = new int[lenA + lenB+1]; int ...

2018-09-04 09:34:46 3881

转载 C++实现数组的全排列

转自作者Jie Qiao专栏:http://blog.csdn.net/a358463121#include <iostream>using namespace std;void swap(int &a,int &b){ int temp=a; a=b; b=temp;}void perm(int list[],int low,i...

2018-09-04 09:21:27 4466 3

原创 把由字符‘C’和‘D’混合的字符串分成前半部分全是‘C’或‘D’所需要的最少步骤

#include <iostream>#include <vector>#include <algorithm>using namespace std;int calcSwapCount(char bc, char ec, char *str, int n){ int count = 0; int begin = 0, end = n ...

2018-09-04 09:14:29 235

原创 C++实现二分查找

#include<iostream>using namespace std;int binarySearch(int *arr , int low , int high , int target)//递归实现{ int middle = (low + high)/2; if(low > high) return -1; if(arr[middle] == tar...

2018-09-01 20:07:48 20005 4

转载 二叉树的各种遍历

摘自 Charles_ke #include<iostream>#include<stack>#include<queue>using namespace std;//节点结构体struct Node{ int value; Node * left; Node * right; Node(int value)...

2018-08-29 13:40:24 407

原创 【希尔排序】C++实现希尔排序代码

#include<iostream>using namespace std;void print(int a[], int n){ for(int j= 0; j<n; j++) { cout<<a[j] <<" "; } cout<<endl; }vo...

2018-08-16 10:42:22 9064 1

原创 【选择排序】C++实现选择排序代码

#include<iostream>using namespace std; void print(int a[], int n){ for(int j= 0; j<n; j++) { cout<<a[j] <<" "; } cout<<endl; }void sel...

2018-08-16 10:09:31 26048 4

原创 单向链表

#include<iostream>using namespace std;class Chain;class Node{ friend class Chain;private: char data; Node *next; };class Chain{public: Chain(); ~Chain(); void ClearList()...

2018-08-11 11:19:05 133

原创 判断一个数是不是素数

程序代码如下:#include<iostream>#include<cmath>using namespace std; int isPrime(int num){ if(num <= 1) return 0; //for(int i = 2; i <= num-1; i++) //从2到num-1整除num,能被整除则不是...

2018-07-02 10:07:03 581

原创 判断一个字符串是不是回文串

程序代码如下:#include<iostream>using namespace std; int check(char *a , int n ){ if(n==0 || n==1) return 1; for(int i=0 ,j = n-1; i<=j; i++,j--) { if(*(a+i) != *(a+j)) return 0; } ...

2018-07-01 21:42:53 869

原创 判断一个数是不是回文数

程序代码如下:#include<iostream>using namespace std; int overturn(int num) //求出你输出的数的倒序数,如:123,返回的倒序是:321{ int num_over = 0; //倒序数的初值设置为0 while(num > 0) //循环的终止条件是num<=0 { num_o...

2018-07-01 10:52:03 366

原创 c++实现顺序查找

程序代码如下:#include<iostream>using namespace std;int SequentialSearch(int *a, int lengh, int key){ for(int i = 0 ; i < lengh ; i++) { if(a[i] == key) return i; ...

2018-06-30 11:54:45 9281 3

原创 c++实现斐波那契数列代码

程序代码如下:#include<iostream>using namespace std;int Fbi(int i) { if (i<2) { return i==0 ? 0:1; } return Fbi(i-1)+Fbi(i-2); } int main() { cout<<Fbi(10)&l...

2018-06-29 21:12:05 19301 1

原创 【插入排序】c++实现插入排序代码

插入排序的基本思想:从第二个元素开始,找到元素的正确位置并插入,直到最后一个元素,则完成排序。就像扑克牌,每拿一张扑克牌都将其插入到正确的位置,拿完所有扑克牌后其为有序状态。程序代码如下:#include<iostream>using namespace std;void print(int a[], int n){ for(int j= 0; j<...

2018-06-29 20:50:21 8666

原创 【冒泡排序】c++实现冒泡排序代码

冒泡排序的基本思想:比较相邻的元素,如果反序则交换。通过第一趟排序能找出最大的元素,并使最大的元素移至最后一位,然后通过第二次排序使次大的元素移至倒数第二位,以此类推,直至所有元素有序。程序代码如下:#include<iostream>using namespace std;void print(int arr[], int n){ for(int j= ...

2018-06-29 16:02:29 89786 2

原创 【快速排序】c++实现快速排序代码

快速排序的基本思想是:通过一次排序将要排序的数据分成两部分,其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按此方法对这两部分数据分别进行快速排序,直到有序。程序代码如下:#include<iostream>using namespace std;void print(int a[], int n){ for(int j= 0; j<n;...

2018-06-28 22:22:34 37794 9

空空如也

空空如也

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

TA关注的人

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