- 博客(34)
- 收藏
- 关注
原创 Reverse Integer leetcode python
class Solution(object): def reverse(self,x): """ :param x:int :return: int """ max_num=2147483647 min_num=-2147483648 flag=0 if x0
2015-12-08 20:47:51
451
原创 Climbing Stairs-python
class Solution(object): def climbStairs(self,n): """ :param n: int :return: int """ t=[1,1] i=2 if n>=2: while in:
2015-12-05 18:46:46
628
原创 python int to binary and count the number of 1
import collectionsclass Solution(object): def hammingWeight(self,n): """ :param n:int :return: int """ k="{0:b}".format(n) m=collections.Counter(k
2015-12-05 16:41:42
447
原创 单链表翻转---C++实现
本文旨在记录单链表翻转,便于日后学习代码如下:#include #include using namespace std;struct node{ int val; struct node *next;};node *reverse_list(node *p){ node *tmp=NULL; while (p) { node *k
2015-10-26 14:29:41
547
原创 C语言标准库常见函数的内部实现
1.从 C标准库 这本书中摘抄。http://book.douban.com/subject/3775842/2.1)memset 概述 #include void *memset(void *s,int c,size_
2015-10-21 10:37:11
671
原创 搜集下面试题目吧---长期更新
1.c/c++内存分配内存分配方式有三种: (1) 从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在。例如全局变量,static变量。 (2) 在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高,但是分配的内存容量有限。
2015-10-20 21:14:46
361
原创 kmp算法--c++ code
此文旨在记录Kmp算法,便于以后复习代码如下:#include #include #include using namespace std;void next_vec(string s1,vector &next){ int k = 0; next.push_back(0); for (int i = 1; i < s1.size(); i++) { w
2015-10-20 15:45:55
406
原创 最长公共子串序列一之两个字符串的最长公共子序列
1.dp矩阵 若s1[i]==s2[j],则dp[i][j]=dp[i-1][j-1]+1; 若s1[i]!=s2[j],则dp[i][j]=max{dp[i-1][j],dp[i][j-1]};2.设定标记矩阵flag 若dp中元素从左上角得来,则flag中元素记为1;若从上边得来,则flag
2015-10-19 20:28:13
657
原创 最长公共子串序列一之 两个字符串的最长公共子串
1.dp矩阵, 第一行/列 若对应字符相同为1,否则为0 其余行/列 若对应字符相同,则为左上角元素加12.设置max_val记录最长的公共字串的长度,并设置flag_i,flag_j为最长公共字串末尾字符在dp矩阵中的位置3.根据max_val及flag_i,flag_j输出最长公共字串代码如下:
2015-10-19 19:13:09
339
原创 图的遍历(PTA题目解答)
mycode:#include #include #include using namespace std;void dfs(vector> a,int i,vector &test,vector &dfs_sub){ test[i] = 1; for (int j = 0; j < a[i].size(); j++) { if (a[i][j] == 1&& !tes
2015-09-07 21:52:54
1311
原创 Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]#include
2015-09-04 17:35:28
416
原创 windows socket编程,连续发送接收
注:改编参考:[1]http://blog.youkuaiyun.com/oinux/article/details/8525823[2]http://www.ibm.com/developerworks/cn/aix/library/0807_liugb_tcpip/流程图服务器端://#include "stdafx.h"#include #include #pragma
2015-08-26 11:28:57
580
原创 c++中判断字符串中是否含有字符'\'
使用'\\'进行判断code:#include #include #include #include using namespace std;int main(int argc, char *argv[]){ string s; cin >> s; for (auto s1 = s.begin(); s1 != s.end(); ++s1) { if (*s
2015-08-24 19:49:45
1807
原创 atoi 和itoa实现
atoi 和itoa实现#include using namespace std;//atoi//原型:int atoi(const char*nptr);//参数nptr字符串,如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,//之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。否则,返回零。int my_atoi(const char *nptr
2015-08-23 20:13:03
448
原创 编程之美-3.5最短摘要的生成
看了下《编程之美》这本书,记录下3.5节的理解。1.题意是什么?题目含义就是在已知字符串S1中搜索含有字符串S2的最小字符串,例如,S1="ABCDEMKFDC",S2="CDK",则应该返回“KFDC”.“含有”意思是什么?即包含即可,不需要相同顺序。原书写的有点拗口,其实对于关键字“微软亚洲研究院 使命”而言,最短摘要为“微软亚洲研究院成立于199
2015-08-19 16:14:57
902
原创 usrp烧写固件支持gnuradio/labview
usrp烧写固件支持gnuradio/labviewEttus和NI的usrp均可以支持labview和gnuradio平台,烧写不同的firmware和FPGA images即可。本文讲述的是如何烧写固件,使得usrp支持gnuradio软件平台。本文不讲述如何安装gnuradio及UHD,讲述的是那些因固件原因仅仅能运行labview软件而不能运行gnuradio的us
2015-07-25 20:36:44
6370
原创 翻转二叉树
1.二叉树初始化,插入数值,填满二叉树2.按层打印原始二叉树3.翻转二叉树4.按层打印翻转后的二叉树代码如下:#include #include #include using namespace std;struct TreeNode{ int val; TreeNode *left; TreeNode *right;};class Solut
2015-07-22 10:52:22
462
原创 排序算法总结一(c++版)
1.插入排序void insert_sort(int a[], int len){ int tmp; for (int i = 1; i <= len - 1; ++i) { for (int j = 0; j < i; ++j) { if (a[i] < a[j]) { tmp = a[j]; a[j] = a[i]; for (in
2015-07-16 11:05:33
434
原创 sizeof(数组名)
1.如果要求一个数组的长度,我们可以采取:int a[]={1,2,3};int len=sizeof(a)/sizeof(int);的形式,然而,此时若有个函数void test(int a[])内部有如下的语句:int len=sizeof(a);此时len=4,求出的是指针的字节数,而非整个数组的字节数。2.发生上述现象的原因是,数组在作为函数参
2015-07-15 09:26:08
1115
转载 static
转载自http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777441.html术语static有着不寻常的历史.起初,在C中引入关键字static是为了表示退出一个块后仍然存在的局部变量。随后,static在C中有了第二种含义:用来表示不能被其它文件访问的全局变量和函数。为了避免引入新的关键字,所以仍使用static关键字来表示这第
2014-07-09 15:40:36
512
转载 GNURadio 中的U O aU aO
转载自 http://blog.youkuaiyun.com/abingzhao/article/details/23913737但是shu 输 出 O U u a 的意义当运行 gnu radio 程序时,会有时看见 O U u a 字符出现在屏幕上。这一般当数据从 USRP 到 PC 机数据输到硬件的时候PC数据速率跟不上。输 出 "O" "U" "u" "a" 的意义
2014-06-02 11:07:10
2118
原创 gnuradio下实现:读symbol进行ifft再写文件
1.首次实现,其实卡在了g++上,使用g++ read_write.cpp -l gnuradio-fft -
2014-05-31 18:45:20
818
翻译 memcpy用法说明
原型:void*memcpy(void*dest, const void*src,unsigned int count); 功能:由src所指内存区域复制count个字节到dest所指内存区域。 说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。
2014-05-31 15:59:22
600
转载 c++ 二维数组简单介绍
一、定义二维数组定义二维数组的一般形式为 类型标识符 数组名[常量表达式][常量表达式]例如 float a[3][4],b[5][10];定义a为3×4(3行4列)的单精度数组,b为5×10(5行10列)的单精度数组。注意不能写成“float a[3,4],b[5,10];”。C++对二维数组采用这样的定义方式,使我们可以把二维数组看作是一种特殊的一维数组:它的元
2014-05-28 15:37:33
1069
转载 C++中的 public protected private friend关键字
转载自 http://blog.youkuaiyun.com/xueer8835/article/details/6441753
2014-05-28 15:01:21
506
转载 ubuntu 12.04 快捷键
转载自 http://hi.baidu.com/renshi168/item/5d1aabbdc01139e84ec7fdd8
2014-05-28 01:06:26
682
转载 ubuntu 12.04 shell 命令下设置代理
转载自:http://hi.baidu.com/wesley2012/item/72b74e8b870c5bcfef083d1bubuntu 12.04的代理设置 安装了ubuntu的最新LTS版本 12.04, 需要重新下载android的源码,由于公司使用了代理服务器,在网络配置方面方面遭遇了各种问题,系统动不动就弹出407 Proxy Authent
2014-05-25 16:25:50
2032
原创 ubuntu下手动切换工作区
系统默认的快捷键:Ctrl+alt+left Ctrl+alt+right Ctrl+alt+up Ctrl +alt+down
2014-05-25 15:27:15
1047
转载 linux下软链接与硬链接 ln命令
转载自 http://www.zhixing123.cn/ubuntu/36216.html符号链接(软链接)是一类特殊的文件, 其包含有一条以绝对路径或者相对路径的形式指向其它文件或者目录的引用。[1] 符号链接最早在4.2BSD版本中出现(1983年)。今天POSIX操作系统标准、大多数类Unix系统、Windows Vista、Windows 7都支持符号链接。Windo
2014-05-24 14:50:31
706
转载 fopen
转载自http://blog.163.com/chentong1115@126/blog/static/45314732200952174226725/
2014-05-17 15:18:26
525
转载 char**
转载自http://blog.youkuaiyun.com/daiyutage/article/details/8604720学习了!深入 char * ,char ** ,char a[ ] ,char *a[] 内核
2014-05-15 01:54:16
497
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人