- 博客(16)
- 资源 (11)
- 收藏
- 关注
原创 c/c++中的const
关于const能否修改c语言#include <stdio.h>int main() { const int i = 10; //const int i; //错误,const变量必须在定义时初始化 //i=100; //错误,const类型不能修改 int *p = &i; //将i的地址赋值给指针p( 在C中ok) *p = 20; //通过指针修改co...
2018-09-19 00:40:18 5347
原创 c++一些常见的知识点
基础知识int *arr[] 是指针数组,数组中存放的是地址int (*arr)[] 是数组指针,首先它是一个指针,它指向一个数组,即指向数组的指针详解解释看这里
2018-09-18 21:44:56 5565
原创 分析两小段c++代码 关于unsigned运算的坑
代码1#include <stdio.h>#include <iostream>using namespace std;int main(){ unsigned int a = 2, b = 1; cout << a - b << endl; cout << b - a << endl; ...
2018-09-18 21:15:05 5539
原创 二叉树的前序、中序、后序非递归遍历 python实现
前言python中二叉树的定义:class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None如何使用python建立一个二叉树前序class Solution: def preorderTr...
2018-09-14 10:00:41 5683
原创 linux 命令行分割字符串的几种方法
使用xargsecho '11@22@33' | xargs -d '@' -n 1 echo | sed '$d' 使用awkecho '11@22@33' | awk -F '@' '{for(i=1;i<=NF;i++){print $i;}}'
2018-09-13 09:25:38 10827
原创 c/c++ 如何输入带空格的字符串
前言如题所示c语言情况常规输入#include <stdio.h>int main(){ char str[10] = {0}; scanf("%s", str); printf("%s\n", str); return 0;}testfasdf asfasdfc语言会自动截断输入的空格问题...
2018-09-09 17:08:19 7755
原创 c++的格式化输出
前言在c++中通过格式化输出的库主要是iomanip 主要是对cin,cout之类的一些操纵运算子,比如setfill,setw,setbase,setprecision等等。它是I/O流控制头文件,就像C里面的格式化输出一样.以下是一些常见的控制函数的:dec 置基数为10 相当于"%d"hex 置基数为16 相当于"%X"oct 置基数为8 相当于"%o"setfill( ...
2018-09-09 15:42:17 7854
原创 二叉树中和为某一值的路径
前言输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。(注意: 在返回值的list中,数组长度大的数组靠前)python 非递归做法利用后序遍历的非递归思想class Solution: # 返回二维列表,内部每个列表表示找到的路径 def FindPath(sel...
2018-09-08 14:28:32 5346
原创 判断某数组是不是二叉树的前序遍历序列 python递归
codeclass Solution: def VerifySquenceOfBST(self, sequence): # write code here if len(sequence) <= 0 or sequence == None: return False length = len(sequence...
2018-09-07 15:33:03 5737
原创 判断某数组是不是二叉树的后序遍历序列 python递归与非递归解法
python 递归class Solution: def VerifySquenceOfBST(self, sequence): # write code here if len(sequence) <= 0 or sequence == None: return False length = len(s...
2018-09-07 15:19:40 5647
原创 判断入栈顺序和出栈顺序是否合理 python实现
前言输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)解题思路1.我们申请一个的新的列表stack,依次将入栈序列中的值加入 2.每次...
2018-09-04 20:52:23 8070
原创 顺时针打印矩阵 python
前言题目:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.思路1.我们依次打印每一行 2.打印完了之后,我们需要删除第一行 3.然后我们需要把整个矩阵逆时针旋转一下,让...
2018-09-04 16:03:38 5615
原创 翻转二叉树 c语言实现 递归 栈 队列
前言题目比较好理解,就是翻转二叉树代码c语言实现#include<stdio.h>#include<stdlib.h>#include<string.h>#define N 105struct TreeNode{ int val; TreeNode* left; TreeNo...
2018-09-04 13:54:24 6899
原创 计算最长公共子序列
前言什么是最长公共子序列呢?好比一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则S 称为已知序列的最长公共子序列。如何解决通用的解法用动态规划,如何使用动态规划解题,晚上已经有很多不同人的答案了,推荐几个: 程序员编程艺术第十一章:最长公共子序列(LCS)问题 算法导论—–最长公共子序列LCS(动态规划)我的代码c语言#in...
2018-09-03 20:42:27 5487
原创 判断两个树是否相等和判断tree1是否包含tree2 python实现
判断两个树是否相等def equal(node_a, node_b): """ 判断两个树是否相等 :param node_a: :param node_b: :return: """ if not node_a and not node_b: return True elif not node_a and ...
2018-09-02 21:46:18 5869
原创 字符串全排列的问题 python和c语言实现
前言这是一个的经典的问题 设计一个算法,输出一个字符串字符的全排列。 比如,String = “abc” 输出是”abc”,”bac”,”cab”,”bca”,”cba”,”acb”解法从集合依次选出每一个元素,作为排列的第一个元素,然后对剩余的元素进行全排列,如此递归处理; 比如:首先我要打印abc的全排列,就是第一步把a 和bc交换(得到bac,cab),这需要一个for循...
2018-09-01 21:18:27 6391
item_seleted
2019-01-22
python画小猪佩奇
2019-01-20
Box2D_v2.1.2已经编译好的文件
2018-11-07
Box2D_v2.1.2
2018-11-07
2018 Google kickstart Problem A. Planet Distance 输入数据
2018-05-27
笨方法学python3 Learn Python 3 the Hard Way
2018-04-06
用python进行数据分析 第二版 Python for Data Analysis, 2nd Edition
2018-04-06
SQL与关系数据库理论:如何编写健壮的SQL代码 第二版
2018-02-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人