![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
文章平均质量分 57
jikiy9
个人网站 https://www.deepdo.vip
展开
-
fopen
转载自http://blog.163.com/chentong1115@126/blog/static/45314732200952174226725/转载 2014-05-17 15:18:26 · 495 阅读 · 0 评论 -
翻转二叉树
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 · 437 阅读 · 0 评论 -
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 · 374 阅读 · 0 评论 -
图的遍历(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 · 1255 阅读 · 0 评论 -
最长公共子串序列一之 两个字符串的最长公共子串
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 · 310 阅读 · 0 评论 -
最长公共子串序列一之两个字符串的最长公共子序列
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 · 601 阅读 · 0 评论 -
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 · 376 阅读 · 0 评论 -
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 · 625 阅读 · 0 评论 -
搜集下面试题目吧---长期更新
1.c/c++内存分配内存分配方式有三种: (1) 从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在。例如全局变量,static变量。 (2) 在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高,但是分配的内存容量有限。原创 2015-10-20 21:14:46 · 333 阅读 · 0 评论 -
windows socket编程,连续发送接收
注:改编参考:[1]http://blog.csdn.net/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 · 543 阅读 · 0 评论 -
char**
转载自http://blog.csdn.net/daiyutage/article/details/8604720学习了!深入 char * ,char ** ,char a[ ] ,char *a[] 内核转载 2014-05-15 01:54:16 · 463 阅读 · 0 评论 -
C++中的 public protected private friend关键字
转载自 http://blog.csdn.net/xueer8835/article/details/6441753转载 2014-05-28 15:01:21 · 483 阅读 · 0 评论 -
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 · 1020 阅读 · 0 评论 -
memcpy用法说明
原型:void*memcpy(void*dest, const void*src,unsigned int count); 功能:由src所指内存区域复制count个字节到dest所指内存区域。 说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。翻译 2014-05-31 15:59:22 · 576 阅读 · 0 评论 -
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 · 485 阅读 · 0 评论 -
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 · 1055 阅读 · 0 评论 -
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 · 397 阅读 · 0 评论 -
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 · 1747 阅读 · 0 评论 -
单链表翻转---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 · 495 阅读 · 0 评论