#include using namespace std;int main () { int a = 3; int b = 5; cout<<"a="<<a<<",b="<<b<<endl; a = a+b; ///a=7 b = a-b; ///b=3; ...
分类:
其他好文 时间:
2014-09-16 18:45:40
阅读次数:
197
为什么研究临时对象?
主要是为了提高程序的性能以及效率,因为临时对象的构造与析构对系统开销也是不小的,所以我们应该去了解它们,知道它们如何造成,从而尽可能去避免它们。临时对象是可以被编译器感知的。
下面的例子,可能有人认为"int temp"是"临时对象",但是其实不然,"int temp"仅仅是swap函数的局部变量。
#include
void swap( int &a,...
分类:
编程语言 时间:
2014-09-16 16:03:10
阅读次数:
217
375. Query on a tree
Problem code: QTREE
You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.
We will ask you to perfrom ...
分类:
其他好文 时间:
2014-09-16 16:00:20
阅读次数:
312
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2014-09-16 15:32:10
阅读次数:
243
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-09-16 13:57:50
阅读次数:
163
TheStrategyPatternis a designpatternto encapsulate the variants (algorithms) and swap them strategically to alter system behavior without changing its...
分类:
其他好文 时间:
2014-09-16 12:25:50
阅读次数:
160
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 le...
分类:
其他好文 时间:
2014-09-16 00:15:49
阅读次数:
196
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路:增加一个头指...
分类:
其他好文 时间:
2014-09-15 22:38:49
阅读次数:
217
Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq...
分类:
其他好文 时间:
2014-09-15 21:09:39
阅读次数:
216
如果应用需要,linux系统所有子目录都可以创建为独立的硬盘分区。没有进行独立分区的子目录都会保存在根目录中。关于swap分区的大小,如果物理内存小于4GB,一般为内存的2倍;如果物理内存大于4GB,而小于16GB,大小可与物理内存相同,如果物理内存大于16GB,可以设为0,但是并不建议将swap设...
分类:
系统相关 时间:
2014-09-15 15:35:29
阅读次数:
221