简单算法
文章平均质量分 74
sorrowllj
这个作者很懒,什么都没留下…
展开
-
基础排序之快速排序
快速排序,方便以后查看 #include "iostream" using namespace std; void QuickSort(int array[],int left , int right); int main(int argc, char const *argv[]) { int TestArray[] = {10,7,5,3,6}; const int MAXNu原创 2015-05-20 14:59:03 · 164 阅读 · 0 评论 -
查找一个String 字符串的某个值,然后替换
大致的思路,先从头到尾扫描下整个字符串,得到有多少个需要被替换的目标字符串,然后通过 find() 和replace() 两个函数将其替换。 但是感觉如果这种处理方式,对一个非常巨大的字符串会耗费相当大的时间,暂时没想出什么好的方法。#include "iostream" #include "string" using namespace std; string findtoReplace(s原创 2015-05-26 12:29:38 · 1163 阅读 · 0 评论 -
基础排序之归并排序
#include "iostream" using namespace std; void MergeSort(int array[],int left,int mid , int right ,int temp[]){ int i = left; int j = mid + 1; int MID = mid; int FIN = right; int k = 0; whil原创 2015-05-20 12:41:25 · 191 阅读 · 0 评论 -
矩阵替换
一个矩阵,凡是出现0的位置,其横列都将被替换为0#include "iostream" #include using namespace std; void zero(int * arraysforfind[] ,int r,int co){ int row = r; int column = co; int *temprow = new int [row]; i原创 2015-06-07 22:31:43 · 861 阅读 · 0 评论 -
LeetCode-OJ
思路:用两个指针,从头开始,向后public static void moveZeroes(int[] nums) { int i=0; int j=0; while(j<nums.length) { if(nums[j]!=0) { if(j!=i) {原创 2015-09-23 13:35:27 · 228 阅读 · 0 评论 -
两个日期之间差
给两个日期格式为x'x'x'x/xx/xx的时间,计算出两个日期的差值,借鉴了一个博客的代码,原地址搜不到了。 #include "iostream" #include "string" #include using namespace std; bool IsLeap(int year) { return (year % 4 ==0 || year % 400 ==0) &&原创 2015-06-16 15:49:04 · 213 阅读 · 0 评论