自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 找出第k大的数字(快排实现+堆排实现)

#include<bits/stdc++.h>using namespace std;int quick_sort(vector<int> &v, int l, int r, int k){ if(l<r){ int target = v[l]; int tmp_l = l, tmp_r = r; ...

2019-09-30 16:57:48 463

原创 二叉树前中后序便利,递归/非递归

普通二叉树的前序中序后序便利,包括递归跟非递归,一共六种,当作复习#include <bits/stdc++.h>using namespace std;priority_queue<long> min_pq;priority_queue<long, vector<long> , greater<long> > max_pq...

2019-09-29 17:05:02 461

原创 C++ 函数同时加上virtual跟inline会怎么样

一般来说,inline是编译时确定,virtual是运行时确定,两者是冲突的,今天笔试遇到一道题,问强行在内联函数前加上virtual会怎么样,一时有点懵比。所以回来之后做了下实验:结论:同时有inline跟virtual的话,inline会被忽略,保留多态特性实验:1.查看加不加virutal后类的大小:inline加上virtual后,类的大小为8,表明有虚函数指针只有inlin...

2019-09-21 13:09:46 978

原创 python-opencv-视频处理常用函数

因为研究方向问题需要先视频处理,方便后面进行检测等,这里记录下常用的,方便以后测试所用的视频:https://media.w3.org/2010/05/sintel/trailer.mp4VideoCapture中get和set函数常用的参数如下,值得注意的是在opencv2版本中需要按下面加上CV_前缀,但是在opencv3中是不需要CV_前缀的,下面19个参数依次对应整数0...

2019-02-27 15:10:21 7013 5

原创 阿里编程题

给出N,K,N代表有N个方块,K代表K种颜色,N*K的矩阵代表第n块涂上第k种颜色的花费,要求找出花费最小的方案输入:4 32 3 29 1 47 8 12 8 3输出:6#include #include #include #include #include #include #include usin

2018-03-09 13:54:57 180

原创 ubuntu下c++链接数据库

首先卸载mysql,因为在用c++链接库时一直找不到,感觉是哪里弄错,所以想要整个卸载重新安装命令如下:sudo apt-get remove mysql-*dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P接着我们要重新安装mysql,以及devel开发包,这是在linux下进行数据库开发需要装的,命令如下:sudo...

2017-07-28 16:29:10 552

原创 面试笔试问到一些问题

通过笔试面试认识到自己很多不足,这里记录下,有些可能会简单记录下答案,详细地可以自行搜索ieg补录笔试,只记得一些印象深的负数取模 a%b=c  =a-(a/b)*bstrcpy memcpy memmove各自特点,主要是还是memmove这个,他比其他两个多了一个拷贝内存重叠的处理,而strcpy针对的是char,根据'\0'结束,而memcpy针对的是各种类型,拷贝整段内存,主要指定拷贝长度...

2017-06-08 18:25:53 391

原创 多态,重写,重载的简单理解

多态是面向对象编程的一种重要思想,只有当程序运行后才能决定调用的函数,是一种动态绑定技术。是通过虚函数来实现,在一个父类中定义了虚函数,然后子类中重写了虚函数,那么只有程序真正运行时才能根据对象去选择调用对应的函数,因为基类指针可以指向不同的子类对象,这时就可以选择调用不同的方法;如果没有多态的,基类指针就只能调用基类本身的方法,就算指向子类也无法调用子类方法。重写(overwrite分成两个,重...

2017-04-06 10:21:56 758

原创 java中初始化顺序

初始化过程是这样的: 1.首先,初始化父类中的静态成员变量和静态代码块,按照在程序中出现的顺序初始化; 2.然后,初始化子类中的静态成员变量和静态代码块,按照在程序中出现的顺序初始化; 3.其次,初始化父类的普通成员变量和代码块,在执行父类的构造方法;4.最后,初始化子类的普通成员变量和代码块,在执行子类的构造方法;

2017-04-06 10:19:42 205

原创 根据前序中序求后序

原理解说(摘自百度)如前序 为 ABDECGF   中序 为 BDACGEF先 根据前序第一个节点 把中序分为BD和CGEF两部分,A为根节点,A左边为左子树,右边为右子树。再把左右子树分别做上述步骤。以此类推 根据第二,第三...个节点构成二叉树  A

2017-04-06 10:18:03 461

原创 随机生成中文(包括编码)

笔试问到,一脸懵逼,记录下来ASCII码是一个字节,但是明显太小了,里面没有中文,所以就有了GBK2312,把中文加进去Unicode是两个字节,够存放所有字符,但是所有字符都用两个字节太浪费空间UTF-8是可变长度字符编码,常用的英文字母被编码成1个字节,汉字通常是3个字节,只有很生僻的字符才会被编码成4-6个字节。在python3中jsom库dump或者load时会默认转...

2017-04-06 10:16:26 2183

原创 python time库常用函数

time.time() #返回1970年后经过的浮点秒数

2017-03-09 17:12:17 2473

转载 软件测试的一些知识点

随便记点东西,当学习吧,为笔试做做准备,内容来自牛客网上粘贴整理的,具体一些名词可以自行百度或者谷歌。软件测试用例包括:输入数据和预期输出结果测试流程:测试计划-测试设计-用例设计-执行测试-测试报告软件测试过程一般有4个步骤:单元测试、集成测试、确认测试、系统测试。 单元测试又称模块测试,是针对软件设计的最小单位——程序模块,进行正确性检验

2017-02-24 22:18:30 477

原创 python学习笔记

因为看实习很多要求要会一门脚本语言,所以来简单学一下python2.7的基本用法吧,下面当成一点笔记。python的输入方式有raw_input跟input,这两种区别为:当输入为纯数字时:input返回的是数值类型,如int,floatraw_inpout返回的是字符串类型,string类型输入字符串为表达式i时:nput会计算在字符串中的数字表达式,而raw_input不会。...

2017-02-21 13:45:52 301

原创 PDF417码的二维码校正以及译码

不想写啥了,直接贴githud链接吧https://github.com/LLuqw/pdf417

2017-02-20 21:27:33 2197

原创 二叉树最大宽度

用两个队列找出二叉树的最大宽度#include #include using namespace std;typedef int T;struct treeNode { T data; struct treeNode *left, *right; treeNode(T d, treeNode *l=NULL, treeNode *r=NUL

2017-02-20 19:57:30 1270

原创 Huffman coding

In computer science and information theory, a Huffman code is an optimal prefix code algorithm.In this exercise, please use Huffman coding to encode a given data.You should output the number of bi

2017-02-20 19:57:18 844

原创 多重背包

Time Limit: 1sec    Memory Limit:256MB DescriptionOuyang has 6 kinds of coins.The number of the i-th coin is N[i] (0Their value and weight are as follewed:0. $0.01, 3g1. $0.05, 5g2. $0

2017-02-20 19:57:06 751

原创 堆排序(小根堆)

void push(int x) { h[++n]=x; int index=n; while(index>1 && h[index]<h[index/2]){ swap(h[index],h[index/2]); index=index/2; } }//在数组后面加多一个元素,进行调整时只需要往上调整,跟父节点比较就好(不用从最后

2017-02-20 19:56:31 646

转载 n皇后问题

DescriptionGiven N queens on an N*N chess board, find the number of ways of placing these queens so that they will not attack each other. InputThere are multiple cases. For each case, th

2017-02-20 19:56:10 366

转载 soj 1034. Forest

方法来源:http://blog.csdn.net/guozhengchun/article/details/40761255判断森林是否合法,以及找出最大宽度跟深度,上面博客的方法很好,是将森林变成树来处理的#include #include #include using namespace std;struct node{ i

2017-02-20 19:55:55 323

原创 Prime Ring Problem

A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number

2017-02-20 19:55:42 158

原创 SOJ 1107. Simple Puzzle

ConstraintsTime Limit: 10 secs, Memory Limit: 32 MB DescriptionHere is a simple puzzle on numbers. There are n numbers, each of which is of k (kn) distinct and significant digits. When t

2017-02-20 19:55:10 412

原创 MFCC

下面内容是当时的实验报告,用word写的。所以直接截图当时的内容,主要是做个记录而已。matlab代码如下:clear;clc;close all;z=[];z1=[];%语音采集 r=audiorecorder(16000,16,1);record(r);%开始录音but_stop=input('

2016-07-15 17:40:03 990

原创 链表加优先队列做拓扑排序

Description John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed.InputThere are mul

2016-07-15 17:21:17 278

原创 hash单词翻译(BKDR)

,大学做的一个小project,利用哈希实现单词翻译,也使用到文件流数组#include #include #include #include #include using namespace std;struct Word{ string english; string chinese; bool exist;

2016-07-15 17:20:23 478

原创 SOJ 1048

BFS#include #include #include #include #include #include using namespace std;struct status{ int k; vector route;};bool check[520];//判断当前情况是否走过 2^9 int main(){ int test; cin >>

2016-07-15 17:19:46 194

原创 K-based Numbers. Version 2

高精度乘法,加法,动态规划DescriptionLet’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For

2016-07-15 17:17:32 251

原创 SOJ 1171

题意:在一块n*m的板子上,有一些细菌,如果一个细菌八个方向上细菌数为2或3,下回合保留,否则消失,如果是一个空格周围细菌数为3,则下回合长出新的,现在给出一种情况,要求出可能得到这种子代的父母有多少种情况解法:因为这道题的规模不是很大n*mn(m),就能将-1变成n-1(m-1),达到连通的效果,然后我是wa了一次,因为数组开太小了,因为说n*m6*6,然后就错了,这个很煞笔。枚举所有情况可

2016-07-15 17:17:08 532

原创 Sicily merge

Given n intervals, you should merge all overlapping intervals. For example, the given intervals are: [1,3],  [2,6],  [3,5], [7,9] you should output: [1,6], [7,9]InputThe first l

2016-07-15 17:16:43 208

转载 动态规划 求两个没交集的区间的和的最大值的范围的左边界

DescriptionReforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). To

2015-05-15 23:25:03 687

转载 阶乘

Many years later, Alice grow up and she become a high-school student.One day she learned factorial on math class. The factorial of an integer N, written N!, is the product of all the integers from 1 t

2015-05-09 19:54:11 339

原创 string

Description    Give you a string S consist of 'a', 'b', 'c'. You can change the string with the follow rule:     1.replace two continuous difference char to a single char.    2.there are 6

2015-05-09 18:06:47 284

原创 数的计算

递推算法找出关系式为:f(n)=f(1)+f(2)+f(3)+...+f(n/2)+1 (n>1)       f(1)=1#include using namespace std;int arr[1001];int main(){ int n; cin >> n; arr[1]=1; for(int i=2; i <=n; ++i){ arr[i]=1;

2015-04-23 17:56:12 273

原创 遍历

题目描述 Description求一棵二叉树的前序遍历,中序遍历和后序遍历输入描述 Input Description第一行一个整数n,表示这棵树的节点个数。接下来n行每行2个整数L和R。第i行的两个整数Li和Ri代表编号为i的节点的左儿子编号和右儿子编号。输出描述 Output Description输出一共三行,分别为前序遍历

2015-04-18 13:49:59 322

原创 找出二叉树的最大宽度和最大深度

给出一个二叉树,输出它的最大宽度和高度。输入描述 Input Description第一行一个整数n。下面n行每行有两个数,对于第i行的两个数,代表编号为i的节点所连接的两个左右儿子的编号。如果没有某个儿子为空,则为0。输出描述 Output Description输出共一行,输出二叉树的最大宽度和高度,用一个空格隔开。

2015-04-18 13:47:18 655

原创 Sicily 2372. Non-Decreasing Digits

用一个数组arr[i][j]储存,i表示有几位数,j表示尾数不大于j的有几个随便写一下就能发现规律:两位数时最后一位大于j的个数分别为:1,3,6  ,10,15,21,28,36  ,45  ,55;两位数时最后一位大于j的个数分别为:1,4,10,20,35,56,84,120,165,220i>=2时:arr[i][j]=arr[i-1][j]+arr[i][j-1]

2015-04-04 09:55:15 512

原创 Sicily 2014. Dairy Queen

类似找零方案#include #include using namespace std;int charge[201];int way[301];int main(){ int n,c; cin >> n >> c; memset(charge,0,sizeof(charge)); memset(way,0,sizeof(way));

2015-04-03 15:32:19 605

原创 Sicily 1093. Air Express

#include using namespace std;int arr[1000000];int main(){ int n1,p1,n2,p2,n3,p3,p4,k=1; while(cin >> n1){ cin >> p1 >> n2 >> p2 >> n3 >> p3 >> p4; int n=0; while(true){ cin >> arr[n];

2015-04-03 15:31:08 280

原创 Sicily 13914. Train Passengers

简单的判断符不符合条件而已,看题比较累。。。在最后一站时注意不能上人也不能有乘客留着#include using namespace std;int main(){ int num=0; int all,sta; cin >> all >> sta; bool check=false; for(int i=0; i < sta; ++i){ int left,ent

2015-03-30 00:40:43 324

空空如也

空空如也

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

TA关注的人

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