- 博客(55)
- 资源 (3)
- 收藏
- 关注
转载 指针与引用的关系
c++中的引用与指针的区别 ★ 相同点: 1. 都是地址的概念; 指针指向一块内存,它的内容是所指内存的地址;引用是某块内存的别名。 ★ 区别: 1. 指针是一个实体,而引用仅是个别名; 2. 引用使用时无需解引用(*),指针需要解引用; 3. 引用只能在定义时被初始化一次,之后不可变;指针可变; 引用“从一而终” ^
2014-11-29 21:31:51 669 1
原创 git的基本使用
git的安装配置1、sudoapt-get install git-core2、配置用户名和邮箱gitconfig user.name “your name”gitconfig user.email “your email”3、生成sshkeyssh-keygen-t rsa -C “your_email@example.com”将key添加到ssh-agent
2014-11-29 21:09:25 741
原创 select检测到可读,调用read的情况
1、当是接收缓冲区的数据大于低潮阀值时,调用read返回实际读出的字节数2、收到FIN,调用read返回的是03、收到RST,调用read返回-1
2014-11-29 19:53:42 3756
原创 valgrind的使用
检测内存泄漏用valgrind --tool=memcheck --leak-check=full 可执行文件名代码如下所示:#include void f(void){ int *x = malloc(10 * sizeof(int)); x[9] = 10;} int main(){ f(); return 0;}编译时添加-g选项:gcc -Wall
2014-11-25 21:46:41 625
原创 windows下netstat的使用
netstat的参数: -a : 显示所有连接和监听端口 -b :显示包含于创建每个连接或监听端口的可执行组件。 -e: 显示以太网统计信息。此选项可以与-s选项组合使用 -n:以数字形式显示地址和端口号 -o: 显示与第个连接相关的所属进程ID -p proto:显示proto指定的协议的连接;proto可以是下列协议之一:TCP, UPD,
2014-11-25 20:14:33 1976
转载 系统调用和库函数调用的区别
从程序完成的功能来看,函数库提供的函数通常是不需要操作系统的服务. 函数是在用户空间内执行的,除非函数涉及到I/O操作等,一般是不会切到核心态的。系统调用是要求操作系统为用户提供进程,提供某种服务,通常是涉及系统的硬件资源和一些敏感的软件资源等。 函数库的函数,尤其与输入输出相关的函数,大多必须通过Linux的系统调用来完成。因此我们可以将函数库的函数当成应用程序设计人员与
2014-11-25 11:08:33 1477
原创 UVa11426 - GCD - Extreme (II)(欧拉函数的妙用)
Given the value of N, you willhave to find the value of G. The definition of G is given below: Here GCD(i,j) means the greatest common divisor of integer i and integer j.
2014-11-23 16:30:00 1814
原创 UVa10541 - Stripe(动态规划,大整数加法)
You are given a rectangle 1*N, where its 1*1 squares can be painted as white or black. So, one can build a "code" of this rectangle - this will be a sequence of numbers, the number of consequent bla
2014-11-23 16:06:22 928
原创 UVa12136 - Schedule of a Married Man(排序)
Last year we set a problem on bachelor arithmetic whichmade some bachelors really unhappy. So to even things up, we are making aproblem on the tough schedule of a married man. Our dashing hero D
2014-11-23 13:30:12 757
原创 UVa10637 - Coprimes(DFS,GCD)
Another gloomy day has begun for Shahriar but as usual hisCD player is singing a song of hope. He has a large piece of paper in front ofhim on which he is trying to partition a number into some co-pri
2014-11-23 12:02:01 910
原创 UVa11857 - Driving Range(并查集)
These days, many carmakers are developing cars that run on electricityinstead of gasoline. The batteries used in these cars are generallyvery heavy and expensive, so designers must make an important t
2014-11-22 16:56:04 778
原创 UVa10264 - The Most Potent Corner
ProblemEvery corner of the N-dimensional (1) unit cube has weight (some positive integer less than 256). We will call two corners neighbouring, if they have common edge. Potency of the corner is t
2014-11-22 15:48:49 694
转载 小端字节序与大端字节序
端模式分为:小端字节序和大端字节序,也就是字节在内存中的顺序。 小端字节序:低字节存于内存低地址;高字节存于内存高地址。如一个long型数据0x12345678 0x0029f458 0x78 0x0029f459 0x56 0x0029f45a 0x34 0x0029f45b 0x12 在以上数据存
2014-11-22 09:59:36 625
原创 二叉树排序的插入
4.请给出二叉树排序的插入算法,节点的数据结构如下typedef structBtNode{int value;struct BtNode*lchild, *rchild;}BtNode;请实现插入算法int Insert(BtNode*root, int value);{ BtNode *prev = NULL, *tmp = NULL;
2014-11-19 22:02:30 1022
原创 看打印输出
4.以下printf打印什么?:int a;short *b = (short *)&a;char *c = (char *)&a;a = 0; *b=1; printf("%x %x %x\n", a, *b,*c);a = 0; *b=256; printf("%x%x %x\n", a, *b, *c);a = 0; *b=-1; p
2014-11-19 21:30:05 634
原创 找错误
4.请找出下面代码中的所有错误,请直接在题目上修改。说明:以下代码是把一个字符串倒序,如“abcd”倒序后变为“dcba” #include"string.h" main() { char*src="hello,world"; char* dest=NULL; int len=strlen(src); dest=(cha
2014-11-19 20:55:29 857
原创 进程通信学习笔记(System V消息队列)
跟Posix消息队列一样,不存在这样的要求:某个进程往一个队列中写入一个消息,另外一个进程下在等待该队列上一个消息的到达系统中的消息队列,定义在头文件中的信息结构:struct1、msgget函数用于创建一个新的消息队列或访问一个已存在的消息队列#include int msgget(key_t key, int oflag);成功返回非负标识符,失败返回-1
2014-11-14 20:25:26 742
原创 LeetCode Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.题意:删除链表中
2014-11-09 18:50:43 596
原创 LeetCode Merge Sorted Array(直接插入排序)
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from
2014-11-08 22:07:04 550
原创 网络编程学习笔记(ioctl操作)
1、ioctrl函数其函数需要的头文件及声明如下:#include int ioctl(int fd, int request, .../*void *arg/);第三个参数总是一个指针,但指针的类型依赖于request把和网络有关的请求分为6类:(1)套接口操作(2)文件操作(3)接口操作(4)ARP高速缓存操作(5)路由表操作(6)流系统
2014-11-08 11:36:39 2575
原创 LeetCode Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.题意:给出两个二叉树,判
2014-11-07 23:33:59 481
原创 LeetCode Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f
2014-11-07 23:25:51 610
原创 网络编程学习笔记(shutdown函数)
终止网络连接的正常方法是close,但close有两个限制,可由shutdown来避免1、close将
2014-11-07 21:00:05 1038
原创 LeetCode Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},
2014-11-05 21:29:45 471
原创 LeetCode Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20
2014-11-05 19:16:17 570
原创 网络编程学习笔记(Unix域套接口地址)
Unix域协议并不是一个实际的协议族,它只是在现一台主机上进行客户-服务通信时,使用与在不同主机上的客户和服务
2014-11-04 21:59:45 997
原创 LeetCode Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?题意:
2014-11-04 18:45:47 455
原创 LeetCode Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.jgu
2014-11-04 18:37:20 478
原创 LeetCode Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2014-11-03 23:03:54 475
Ubuntu Linux实用学习教程.pdf
2009-09-11
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人