上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
摘要: #include #include #include #ifdef __linux #include #include #endif void swap(int64_t* A, uint64_t i, uint64_t j) { int64_t tmp = A[i]; A[i] = A[j]; A[j] = tmp; } int64_t ... 阅读全文
posted @ 2015-02-10 10:56 孙永杰 阅读(667) 评论(1) 推荐(0) 编辑
摘要: 以下摘自网络 随机化快排:快速排序的最坏情况基于每次划分对主元的选择。基本的快速排序选取第一个元素作为主元。这样在数组已经有序的情况下,每次划分将得到最坏的结果。一种比较常见的优化方法是随机化算法,即随机选取一个元素作为主元。这种情况下虽然最坏情况仍然是O(n^2),但最坏情况不再依赖于输入数据,而是由于随机函数取值不佳。实际上,随机化快速排序得到理论最坏情况的可能性仅为1/(2^n)。所以随机化... 阅读全文
posted @ 2015-02-10 10:00 孙永杰 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 不说狠话,不做软事 阅读全文
posted @ 2015-02-09 21:12 孙永杰 阅读(476) 评论(0) 推荐(0) 编辑
摘要: #include #include #ifdef __linux #include #endif // MINIMUM(A) // MIN = A[1] // for i = 2 to A.length // if min > A[i] // min = A[i] // return min int64_t minimum(int64_t* A, i... 阅读全文
posted @ 2015-02-09 20:27 孙永杰 阅读(285) 评论(0) 推荐(0) 编辑
摘要: #include struct msg { struct msg *m_next; /* ... more stuff here ... */ int m_id; }; msg* workq; pthread_cond_t qready = PTHREAD_COND_INITIALIZER; pthread_mutex_t qlock = PTH... 阅读全文
posted @ 2015-02-09 17:35 孙永杰 阅读(450) 评论(0) 推荐(0) 编辑
摘要: svn ci失败, 考虑使用 svn del --force 来删除有问题的目录和文件,不行的话再使用svn resolve --accept=working LinerTimeMaxSubarray(提示有冲突的文件或者目录)svn cleanup就应该可以解决了 阅读全文
posted @ 2015-02-09 15:17 孙永杰 阅读(310) 评论(0) 推荐(0) 编辑
摘要: 1 // add_item.cc 2 #include 3 #include "Sales_item.h" 4 5 int main(int argc, char** argv) 6 { 7 Sales_item item1; 8 Sales_item item2; 9 10 std::cin >> item1 >> item2; ... 阅读全文
posted @ 2015-02-07 23:46 孙永杰 阅读(228) 评论(0) 推荐(0) 编辑
摘要: // threads/mutex1.c 11-5 #include #include #include struct foo { int f_count; pthread_mutex_t f_lock; int f_id; /* ... more stuff her... 阅读全文
posted @ 2015-02-07 17:56 孙永杰 阅读(276) 评论(0) 推荐(0) 编辑
摘要: http://www.apuebook.com/errata2e.html Welcome to the web site dedicated to the support of the second edition of Advanced Programming in the UNIX® Environment. The following errors were fixed in the ... 阅读全文
posted @ 2015-02-07 17:04 孙永杰 阅读(228) 评论(0) 推荐(0) 编辑
摘要: cd /etc/yum.repos.d sudo wget http://people.centos.org/tru/devtools/devtools.repo sudo yum --enablerepo=testing-devtools-6 install devtoolset-1.0 export PATH=/opt/centos/devtoolset-1.0/root/usr/bin/:... 阅读全文
posted @ 2015-02-07 11:58 孙永杰 阅读(464) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页