- 博客(38)
- 资源 (25)
- 收藏
- 关注
原创 (leetcode 99) Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devis
2016-02-01 15:49:25
624
原创 (leetcode #55)Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2016-01-31 14:20:16
535
原创 (leetcode #10)Regular Expression Matching --递归法
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st
2016-01-28 12:06:20
718
原创 bind 返回(Can't assign requested address)
macbook上错误码是49()我绑定本地ip为255.255.255.255的时候出错(macbook),但是在linux下就正确,两个系统差别还是很大的解决方式是:只指定port,不要指定addr
2016-01-14 18:11:41
3065
原创 Singleton
#include class Person{private: static Person *singlePerson; Person() { std::cout<<"Create Person"<<std::endl; } ~Person() { std::cout<<"Delete Person"<<std::endl; } class CGarInner{//
2015-09-16 16:22:13
415
转载 ffmpeg ios 编译
参考:http://blog.youkuaiyun.com/cpluser/article/details/41282817编译环境*Mac OS 10.10 with Xcode5.1*以编译ffmpeg2.0版本为例 第一步: 下载build-ffmpeg.sh脚本 见链接第二步: 下载gas-preprocessor.pl脚本,
2015-04-02 14:34:37
749
转载 FFMPEG之TimeBase成员理解
From:http://blog.youkuaiyun.com/supermanwg/article/details/14521869FFMPEG的很多结构中有AVRational time_base;这样的一个成员,它是AVRational结构的typedef struct AVRational{ int num; /// int den; ///} AVRation
2015-03-25 18:11:26
725
转载 FFMPEG 中dts和pts区别
CopyFrom:http://www.cnblogs.com/yinxiangpei/articles/3892982.html视频的显示和存放原理对于一个电影,帧是这样来显示的:I B B P。现在我们需要在显示B帧之前知道P帧中的信息。因此,帧可能会按照这样的方式来存储:IPBB。这就是为什么我们会有一个解码时间戳和一个显示时间戳的原因。解码时间戳告诉我们什么
2015-03-25 17:46:19
17257
原创 Linux 下TCP简单通信
//TCP server#include#include#include#include#include#include#includeint main(){int fd;int fd1;struct sockaddr_in server_addr;struct sockaddr_in cl
2015-03-25 14:20:31
560
原创 FFMPEG 实时流媒体 客户端 大致流程
@property unsigned int bActivitying;@property AVFormatContext *pFormatCtx;//video@property struct AVCodecContext *pVideoCodecCtx;@property struct AVFrame *
2015-01-28 17:46:59
1245
原创 Topological Sort
#include#include#includeusing namespace std;class Node{public: Node(string data) { this->data=data; begin=0; finish=0; color="white"; p=NULL; } string data; int begin; int finish
2014-11-16 14:25:28
605
转载 通过rtsp获取H264裸流并保存到mp4文件
copy from http://www.cnblogs.com/wenjingu/p/3990071.html
2014-11-13 12:22:18
19170
转载 Win Socket-Raw
// RawSock.cpp : Defines the entry point for the console application.//#define _WINSOCK_DEPRECATED_NO_WARNINGS#include "stdio.h"#include "winsock2.h"#include "ws2tcpip.h" //IP_HDRINCL is here
2014-09-09 17:23:09
3315
原创 Linux下UDP的简单例子
http://blog.sina.com.cn/s/blog_85882089010159bd.html客户端代码 client.c#include #include #include #include int main(int argc, char **argv){ int sockfd; struct sockaddr_in se
2014-08-27 09:51:18
992
原创 Margin-Border-Padding
.margin-border-padding{ word-break:break-all; height:150px; background-color: yellow; margin: 0px 20px 30px 40px; border: 3px solid red; border-top-style:dashed; padding: 30px 20px 6px 1
2014-07-28 00:18:14
818
转载 内存对齐
from http://blog.chinaunix.net/uid-10995602-id-2918694.html 在最近的项目中,我们涉及到了“内存对齐”技术。对于大部分程序员来说,“内存对齐”对他们来说都应该是“透明的”。“内存对齐”应该是编译器的 “管辖范围”。编译器为程序中的每个“数据单元”安排在适当的位置上。但是C语言的一个特点就是太灵活,太强大,它允许你干预“内存
2014-03-10 09:31:23
574
转载 VC++中delete和delete [] 的区别
我们通常从教科书上看到这样的说明:delete 释放new分配的单个对象指针指向的内存delete[] 释放new分配的对象数组指针指向的内存那么,按照教科书的理解,我们看下下面的代码:int *a = new int[10];delete a; //方式1delete [] a; //方式2肯定会有很多人说方式1肯定存在内存泄漏,是这样吗?
2014-03-10 09:29:57
802
转载 函数数组
#include#includeusing namespace std;int f1(char *);int f2(char *);int f3(char *);int f4(char *);int f5(char *);int (*ftk[5])(char *pStr)={ f1,f2,f3,f4,f5,};int f1(char *pStr){ cout<<p
2013-02-27 20:13:03
475
原创 一个简单的算法2
#include#include#include#includeusing namespace std;void main(){ float a=1.0f; cout<<(int)a<<endl; cout<<&a<<endl; cout<<(int&)a<<endl; cout<<boolalpha<<((int)a == (int&)a)<<endl
2012-12-11 22:25:34
528
原创 先序中序后序非递归遍历
#include#include#includeusing namespace std;class Node{public: Node(char data,Node *left,Node *right):data(data),left(left),right(right),flag(false){} char data; Node *left,*right;
2012-10-09 00:06:29
680
转载 连续乘积最大值
From : http://topic.youkuaiyun.com/u/20071203/19/136ed1e8-993a-498c-8b03-9caa6965c432.html?1405646013 #include int max(int i,int j,int k) //取最大数{if (j>i) i=j;if (k>i) i=k;return i;}
2012-09-20 13:25:28
700
原创 一些简单的算法
#include#includeusing namespace std;//汉诺塔void Hano(int n,char A,char B,char C){ if(n==1) { cout"<<C<<endl; } else { Hano(n-1,A,C,B); cout"<<C<<endl; Hano(n-1,B,A,C);
2012-09-04 00:47:44
525
原创 找最低公共父节点
树的算法,用递归很方便,尽管复杂度可能较高。using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class Node { public Node left; public Node
2012-08-22 22:42:49
1119
原创 重写全局的new ,delete
#include #include #include #includeusing namespace std;void* operator new(size_t size){ std::cout<<"operator new:"<<size<<" Byte"<<endl; void* m= malloc(size); if(!m) cout<<"o
2012-08-15 22:59:37
1545
转载 寻找“捣乱分子”对[
转载:http://blog.youkuaiyun.com/wuzhekai1985/article/details/6718256 问题描述:多人排成一个队列,我们认为从低到高是正确的序列,但是总有部分人不遵守秩序。如果说,前面的人比后面的人高(两人身高一样认为是合适的),那么我们就认为这两个人是一对“捣乱分子”,比如说,现在存在一个序列:176, 178, 180, 170, 171
2012-07-30 22:10:10
1117
原创 扔骰子,求概率
n 个骰子的点数。把n 个骰子扔在地上,所有骰子朝上一面的点数之和为S。输入n,打印出S 的所有可能的值出现的概率。ANSWER:All the possible values includes n to 6n. All the event number is 6^n.For nf(S,n) = f(S-6, n-1) + f(S-5, n-1) + … + f(S-1, n-1)
2012-07-29 18:19:50
857
原创 将一个n元素的数组平均分为m分,是每组和相等,求最大m
网上流行的一道题目,题目如下。最终利用穷取法来递归解决的。一个整数数组,长度为n,将其分为m 份,使各份的和相等,求m 的最大值比如{3,2,4,3,6} 可以分成{3,2,4,3,6} m=1;{3,6}{2,4,3} m=2{3,3}{2,4}{6} m=3 所以m 的最大值为3using System;using System.Collections.Generic;
2012-07-28 17:46:19
5407
原创 8大基础排序
#includeusing namespace std;//bubble sortvoid BubbleSort(int *arr,int left,int right){ int temp; for(int i=right-1;i>=left;i--) { for(int j=left;j<=i;j++) { if(arr[j]>arr[j+1]) {
2012-07-28 11:57:55
622
原创 和为n 连续正数序列
static void Main() { int Sum = 33; int N = (int)(Math.Sqrt(2 * Sum) + 1.0); for (int i = 2; i <= N; i++) { int an = Sum -
2012-07-20 21:55:11
858
原创 球队比赛问题
public static void Main() { int[] order = new int[] { 5, 0, 4, 1, 6, 2, 3 }; int[,] pk = new int[,] { {0, 0, 0, 3, 4, 0, 6},
2012-07-17 15:40:03
1649
原创 编程之美 数组分割 (能打印具体数据)
#include#include#include#include#include#include#include#include#include using namespace std;int main(){ const int N=4; int a[N+1]={0,4,3,7,1}; int sum=0; for(int i=0
2012-07-16 23:07:35
568
原创 寻找最长等差数列
(时间复杂度有点高,但是不知道如何优化了,如何更好DP) using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { //从一个已经排好序的数组中找出
2012-06-26 18:30:18
1174
原创 计算前N个数字钟1的个数(编程之美2.4 1的数目)
#include "point.h"using namespace std;int CalcOneHelp(int);int CalcOne(int);int power(int ,int);int CalcOne(int N)//穷举法,比较傻瓜,思路简单,运算速度慢{ int sum=0; for(int i=1;i<=N;i++) sum+=CalcOneHelp(i)
2012-06-16 14:10:38
886
原创 字符串距离(编程之美题目) &&& 最长公共子序列(算法导论)
字符串的距离,编程之美上给了一个最简答的递归的做法,显示时间复杂度很高,要写的更好一些,就必须是DP,C++代码如下:题目如下: 许多程序会大量使用字符串。对于不同的字符串,我们希望能够有办法判断其相似程度。我们定义了一套操作方法来把两个不相同的字符串变得相同,具体的操作方法为:1. 修改一个字符 (如 把“a”替换为“b”)。2. 增加一个字符 (如把“abdd”变
2012-06-09 18:12:39
1278
原创 一个数组算法题,利用递归-回溯求解
给你10 分钟时间,根据上排给出十个数,在其下排填出对应的十个数要求下排每个数都是先前上排那十个数在下排出现的次数。上排的十个数如下:【0,1,2,3,4,5,6,7,8,9】举一个例子,数值: 0,1,2,3,4,5,6,7,8,9分配: 6,2,1,0,0,0,1,0,0,00 在下排出现了6 次,1 在下排出现了2 次,2 在下排出现了1 次,3 在下排出现了
2012-05-25 23:13:20
535
原创 策略模式 ----- 排序例子
策略模式定义了一系列的算法,并将每一个算法封装起来,而且使它们还可以相互替换。策略模式让算法独立于使用它的客户而独立变化。(原文:The Strategy Pattern defines a family of algorithms,encapsulates each one,and makes them interchangeable. Strategy lets the algorithm v
2012-05-07 15:12:19
1268
原创 二分查找
using System;using System.Collections.Generic;using System.Text;using System.Collections;using System.IO;using System.Threading;using System.IO.Ports;namespace Program{ class Program
2012-05-05 15:37:48
688
ms-dos 71f 操作系统
2014-05-27
C#基础教程 英文版 CSharp How to Program.pdf
2012-04-29
understanding the linux kernel (英文版)
2011-12-22
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人