- 博客(49)
- 资源 (10)
- 收藏
- 关注
原创 乐其面试题-求数组的最大三个数
#includeusing namespace std;void main(){ int a[]={3,6,2,3,1,3,1,9,3,7}; int onemax,secmax,thrmax; onemax=secmax=thrmax=a[0]; for(int i=1;i<sizeof(a)/sizeof(a[0]);i++) { if(onemax<a[i])
2014-10-30 12:54:47
1363
原创 百度面试题之 循环链表求出最短的包括所有元素的字串长度
#includeusing namespace std;void main(){ int qu[13]={0,1,2,2,2,2,2,3,1,3,3,2}; int i,j,value=0,min=14,count; for(i=0;i<13;i++) { count = 0; value = 0; for(j=i;(j+1)%13!=i;j=(j
2014-10-18 08:38:03
1320
原创 自定义字符串操作
#include#include#include#includeusing namespace std;class HString{private: char kind[2]; //操作类型 char *str; //字符串 int length;
2014-07-16 09:45:50
946
原创 matlab 蒙特卡洛
l = 1;n = 50000;m = 0;for k = 1: n x = unifrnd(0,1); y = unifrnd(0,1); if y < sqrt(1-x^2) m = m+1; endendm/n
2014-07-09 14:09:06
1917
原创 matlab 统计总结
方法一:tabulateTABLE = TABULATE(X), where X is a character array or a cell array of strings, returns TABLE as a cell array
2014-07-09 14:03:04
1158
原创 面试题
1.输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。#includeusing namespace std;struct BSTreeNode{ int m_Value; BSTreeNode *m_pLeft; BSTreeNode *m_pRight;};typedef BSTreeNode *DoubleList,*BSTree;DoubleList phe
2014-06-16 18:22:03
1308
原创 大数阶乘
求大数阶乘#include#include#include#includeint data[100000];void main(){ int m,n,i,j,len,t,temp; printf("请输入一个数组元素存多少位:"); scanf("%d",&m); t = (int)pow(10.0,m*1.0); printf("请输入
2014-06-13 10:55:42
731
原创 opencv轮廓提取
#include#include#includeusing namespace std;using namespace cv;int threshval = 160;int main(){ Mat img = imread("f:/mei.jpeg"); Mat gray ; cvtColor(img,gray,CV_RGB2GRAY); namedWindow("image
2014-06-09 20:04:38
2399
原创 数据拆分
不重复:#include#define N 20int stack[N];int top=0;void fun(int m,int n){ int i; if(n<=0 || m<=0) return; if(m==n) { stack[top++]=n; for(i=0;i<top;i++) printf("%d ",stack[i
2014-05-20 20:30:07
742
原创 STL for_each sort
#include#include#includeusing namespace std;void print(int elem) //自定义打印函数{ cout<<elem<<" ";}bool compare(int a, int b) //自定义排序函数规则{ return b<a;}void main(){ int a[]={1,2,1,3}; vector
2014-05-19 15:23:46
773
原创 stl accumulate transform
#include#include#include#include#includeusing namespace std;void main(){ //整数累加 int a[4]={12,34,44,55}; vector aint(a,a+4); int num = accumulate(aint.begin(),aint.end(),0); cout<<num<<end
2014-05-18 14:53:52
849
原创 c++ 随机生成社区数据
#include#include #include#include#include#include#includeusing namespace std;const int N = 1000005;vector g[N];map > mp;int getRand(int n){ int value = (rand()%n)*(rand()%n); //printf("%
2014-05-18 13:24:15
796
原创 lingo 简单整数组合问题
sets: s/n1..n22/:n,value;endsetsdata:value =55413.1534039.7829854.2138571.9331912.7644664.7967553.0361702.5883413.7292970.95279503.02265720.6260921.02117565.8535437.7134207.975672
2014-05-15 21:45:35
1260
转载 Meansift
function [] = select()close all;clear all;%%%%%%%%%%%%%%%%%%根据一幅目标全可见的图像圈定跟踪目标%%%%%%%%%%%%%%%%%%%%%%%I=imread('e:/jiansheng.jpg');figure(1);imshow(I);[temp,rect]=imcrop(I); %用户手选裁剪的区域[a,b,c
2014-05-15 13:36:34
1070
原创 python 无向图的生成
import random#n = int(input("please input n:"))#m = int(input("please input m:"))#vote = int(input("please input vote:"))#print(int(random.uniform(1,vote)))n = 4m = 6v = 3source ={}for i in
2014-05-14 13:56:39
9786
原创 opencv 形态学
#include#includeusing namespace std;using namespace cv;Mat src;int sizeval=3;static void on_tracker(int ,void *){ Mat out; Mat element = getStructuringElement(MORPH_RECT,Size(sizeval,sizeva
2014-05-14 10:31:11
962
原创 opencv 滤波
方框#include#includeusing namespace std;using namespace cv;Mat src;int sizeval=3;static void on_tracker(int ,void *){ Mat src1 = src; Mat out; boxFilter(src1,out,-1,Size(sizeval,sizeval
2014-05-13 20:51:40
833
原创 opencv tracker
#include#includeusing namespace std;using namespace cv;Mat src;int threshval=128;static void on_tracker(int ,void *){ Mat bin = src<threshval; //设置阈值 imshow("src",bin);}int main(){ s
2014-05-13 14:02:22
2772
原创 opencv split和merge操作
#include#include#include#includeusing namespace cv;using namespace std;int main(){ Mat srcImage=imread("e:/huangshan.jpg"); Mat imageBlue,imageGreen,imageRed; Mat mergeImage; //定义一个Mat向量容器保
2014-05-13 09:38:16
32905
原创 sscanf简单用法
拆分#includevoid main(){ char str[100]="123 ahdkf 345 sdhk 5 6 sdhk 7 sdfh 22 33"; char *pStr=str; int a; while(*pStr) { if(pStr == str && sscanf(pStr,"%d",&a)==1) p
2014-05-12 10:24:29
792
原创 matrix 重载操作,firend 函数实现 简单的例子
#include#define MAX 10using namespace std;class matrix;matrix& operator-(matrix& b,const matrix& c);class matrix{private: int row,col,(*a)[MAX];public: matrix(){} matrix(int r,int c,int (*b
2014-05-11 15:06:28
888
原创 heap中取出k个最小值
#includeusing namespace std;void MaxHeap(int heap[],int i,int len){ int largeIndex = -1; int left =i*2; int right =2*i+1; if(left heap[i]) largeIndex = left; else largeIndex = i; if (righ
2014-05-09 16:09:59
840
原创 字符串中查找字符串的位置
#includeusing namespace std;void findstr(char* src,char *dst){ int i=0,j=0,pos; for(;src[i];) { j=0; if(src[i]==dst[j]) { pos=i; while(dst[j]&&sr
2014-05-08 15:44:53
1423
原创 C显示系统时间
#include#includevoid main(){ time_t tim; struct tm *at; char now[40]; time(&tim); at=localtime(&tim); strftime(now,40,"%Y%m%d\n",at); puts(now); at->tm_mon+=3; strf
2014-05-06 18:20:56
1113
原创 C语言 递归拆分数字
#includeint stack[100];int top;int total,n;void dfs(int index){ int i; if(total==n) { printf("%d=",n); for(i=0;i<top-1;i++) printf("%d+",stack[i]); printf("%d\n",stack[top-1]);
2014-05-06 12:42:32
5264
原创 VideoCapture
#include#includeusing namespace std;using namespace cv;int main(){ VideoCapture capture; capture.open("C:/Users/Administrator/Desktop/OpenTLD-master/datasets/06_car/car.mpg"); if(!capture.i
2014-04-30 16:57:25
4684
原创 vector二维操作
vector >vt; // vt.push_back(vector(10,1)); vt.push_back(vector(10,2)); for(vector >::iterator it=vt.begin();it!=vt.end();it++) { for(vector::iterator it1=it->begin();it1!=it->end();it1++) co
2014-04-30 11:02:30
5855
原创 Opencv Mat操作大全
#include#includeusing namespace std;using namespace cv;int main(){ float array[]={1,2,3}; float array1[]={2,3,1}; //用数组初始化Mat Mat mat=Mat(1,3,CV_32F,array); Mat mat1=Mat(1,3,CV_32F,array1);
2014-04-29 16:49:50
28372
原创 微软
第一题:把二元查找树转变成排序的双向链表 题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。 10 / \ 6 14 / \ / \4 8 12 16 转换成双向链表4=6=8=10=12=14=16。 首先我们定义的二元查找树 节点的数据结构如下:
2014-04-25 15:18:52
887
转载 sift,surf匹配代码
#include "opencv2/highgui/highgui.hpp"#include "opencv2/calib3d/calib3d.hpp"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/features2d/features2d.hpp"#include "opencv2/nonfree/nonfree.hpp"
2014-04-23 16:24:17
5955
原创 hdu-acm
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +
2014-04-23 15:38:31
850
原创 华为
#includeusing namespace std;void stringZip(const char *pInputStr, long lInputLen, char *pOutputStr){ int count,pos=0; char temp; for(int i=0;i<lInputLen;) { count=0; temp=pInputStr[i]
2014-04-23 14:38:42
1012
原创 Number Sequence
Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).Input
2014-04-22 14:38:53
6054
原创 python3.3 爬虫小例子
本文仿照大神:http://blog.youkuaiyun.com/pleasecallmewhy/article/details/8927832 的博客转化成python3.3第一个爬虫小例子:import urllib.request as requestimport urllib.parse as parseimport stringprint("""++++++++++++++++++
2014-04-20 14:41:19
39759
原创 BeautifulSoup 对象方法
from bs4 import BeautifulSoup,Tag,CDataimport redoc = ['Page title', 'This is paragraph one.', 'This is paragraph two.', '']soup = BeautifulSoup(''.join(doc))print(soup.pret
2014-04-19 21:38:57
1976
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人