摘要: Given an integer, write a function to determine if it is a power of two.class Solution {public: bool isPowerOfTwo(int n) { while(n)... 阅读全文
posted @ 2016-04-17 23:53 Free_Open 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> ... 阅读全文
posted @ 2016-04-17 23:37 Free_Open 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 运行命令:g++ -fopenmp xx.cpp -lgomp -lpthread -o xx.out 用例一: #include #include #include void test (int n) { for(int i = 0; i #include #include... 阅读全文
posted @ 2016-04-17 23:16 Free_Open 阅读(328) 评论(0) 推荐(0) 编辑
摘要:  为什么需要知道C/C++的内存布局和在哪可以可以找到想要的数据?知道内存布局对调试程序非常有帮助,可以知道程序执行时,到底做了什么,有助于写出干净的代码。本文的主要内容如下: 源文件转换为可执行文件 可执行程序组成及内存布局 数据存储类别 一个实例 总结 源文件转换为可执行文... 阅读全文
posted @ 2016-04-17 18:54 Free_Open 阅读(766) 评论(0) 推荐(0) 编辑
摘要: 先看一段代码#includeusing namespace std;#define n 510void sum(int a,int b){ cout<<a+b<<endl;}void init(int (*a)[n],int (*b)[n]){ for(int i=0;... 阅读全文
posted @ 2016-04-17 18:50 Free_Open 阅读(1219) 评论(0) 推荐(0) 编辑
摘要:  经常使用 top 命令了解进程信息,其中包括内存方面的信息。命令top帮助文档是这么解释各个字段的。 VIRT , Virtual Image (kb) RES, Resident size (kb) SHR, Shared Mem size (kb) %MEM, Memory usag... 阅读全文
posted @ 2016-04-17 18:29 Free_Open 阅读(2950) 评论(0) 推荐(0) 编辑
摘要: 1. const char* 和string 转换 (1) const char*转换为 string,直接赋值即可。 EX: const char* tmp = "tsinghua". string s = tmp; (2) string转换为co... 阅读全文
posted @ 2016-04-17 18:11 Free_Open 阅读(502) 评论(0) 推荐(0) 编辑