02 2015 档案

摘要:#include #include int MyAtoi(const char* str) { if (str == NULL) return 0; int slen = strlen(str); if(slen ='0')&&(*c <= '9')) { t = *c-'0'; ret = ret *10+... 阅读全文
posted @ 2015-02-28 21:06 孙永杰 阅读(626) 评论(2) 推荐(0) 编辑
摘要:使用root用户打开eclipse help –> install new software http://viplugin.com 破解 使用root用户 在eclipse根目录下建立文件:viPlugin2.lic。并使用记事本打开,将以下字符串插入其中: q1MHdGlxh7nCyn_FpHaVazxTdn1tajjeIABlcgJBc20 2、重启eclipse vipl... 阅读全文
posted @ 2015-02-28 20:17 孙永杰 阅读(447) 评论(0) 推荐(0) 编辑
摘要://class Resource {//public:// Resource(parms p): r(allocate(p)) { }// ~Resource() { release(r); }// // also need to define copy and assignmen... 阅读全文
posted @ 2015-02-28 18:33 孙永杰 阅读(318) 评论(0) 推荐(0) 编辑
摘要:新建工程,makefile project with existing code选择目录,在目录下新建makefile文件,makefile文件中要有all : 这样的字样and work with github 阅读全文
posted @ 2015-02-28 09:56 孙永杰 阅读(1270) 评论(0) 推荐(0) 编辑
摘要:函数返回值,不要使用void。 只有两种可能的,使用bool, 绝大部分使用int64_t 阅读全文
posted @ 2015-02-27 08:34 孙永杰 阅读(160) 评论(0) 推荐(0) 编辑
摘要:/* * IA_22.2BreadthFirstSearch.h * * Created on: Feb 13, 2015 * Author: sunyj */ #ifndef IA_22_2BREADTHFIRSTSEARCH_H_ #define IA_22_2BREADTHFIRSTSEARC... 阅读全文
posted @ 2015-02-26 19:33 孙永杰 阅读(402) 评论(0) 推荐(0) 编辑
摘要:文件 xstartup加上两句最后一句解决输入法问题#twm &gnome-session &scim -d 阅读全文
posted @ 2015-02-26 15:23 孙永杰 阅读(115) 评论(0) 推荐(0) 编辑
摘要:eclipse关于字符编码的设置 阅读全文
posted @ 2015-02-24 13:29 孙永杰 阅读(186) 评论(0) 推荐(0) 编辑
摘要:如果需要使用 INT64_MAX ,在centos 64位下,需要使用g++ 4.7.0 then -std=c++11, -std=c++0x也不行 阅读全文
posted @ 2015-02-13 20:10 孙永杰 阅读(170) 评论(0) 推荐(0) 编辑
摘要:最好不要使用"string.h",stdint.h,iostream.h这样的头文件,这些都是C的头文件习惯使用 阅读全文
posted @ 2015-02-13 19:59 孙永杰 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2015-02-12 20:39 孙永杰 阅读(269) 评论(0) 推荐(0) 编辑
摘要:转自 http://www.cnblogs.com/Anker/archive/2013/01/27/2879150.html 我还怕将来这篇日志被删除,所以粘贴了过来,这篇是一字未改的转贴 摘要: 本章介绍了散列表(hash table)的概念、散列函数的设计及散列冲突的处理。散列表类似与字典的目录,查找的元素都有一个key与之对应,在实践当中,散列技术的效率是很高的,合理的设计散函数和... 阅读全文
posted @ 2015-02-12 17:09 孙永杰 阅读(191) 评论(0) 推荐(0) 编辑
摘要:/* * IA_11.4OpenAddressing.h * * Created on: Feb 13, 2015 * Author: sunyj */ #ifndef IA_11_4OPENADDRESSING_H_ #define IA_11_4OPENADDRESSING_H_ #include #include #include class No... 阅读全文
posted @ 2015-02-12 16:34 孙永杰 阅读(862) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2015-02-12 13:50 孙永杰 阅读(693) 评论(0) 推荐(0) 编辑
摘要:11.2是第11章的主要内容,11章叫散列表(Hash Tables)11.2也叫散列表(Hash Tables) 11.3节讲散列函数(比如除尘散列法),11.4节讲处理碰撞的另外一种方法区别于链式法技术 散列技术,有两个事情要做,一是先哈希函数(11.3),二是解决碰撞技术(11.2链式解决碰撞,11.4开放寻址解决碰撞)。 /* * IA_11.2Cha... 阅读全文
posted @ 2015-02-12 12:53 孙永杰 阅读(627) 评论(0) 推荐(0) 编辑
摘要:带哨兵的双向链表,代码中我使用了nullptr,所以需要编译器升级,我的编译器是gcc/g++ 4.7.0这是可以的,编译的时候加参数—std=c++0x 节点中还可能有卫星元素 /* * IA_10.2LinkedLists.h * * Created on: Feb 13, 2015 * Author: sunyj */ ... 阅读全文
posted @ 2015-02-12 10:37 孙永杰 阅读(258) 评论(0) 推荐(0) 编辑
摘要:不要忘记 –std=c++0x,想要使用c++ 0x的内容,必须,1,升级编译器,2,编译时加上—std=c++0x 阅读全文
posted @ 2015-02-12 08:43 孙永杰 阅读(454) 评论(0) 推荐(0) 编辑
摘要:散列表比直接存储的唯一好处是,节省空间 阅读全文
posted @ 2015-02-11 19:58 孙永杰 阅读(259) 评论(0) 推荐(0) 编辑
摘要:注意n个空间的队列,有最多n - 1个元素 /* * IA_10.1queue.h * * Created on: Feb 13, 2015 * Author: sunyj */ #ifndef IA_10_1QUEUE_H_ #define IA_10_1QUEUE_H_ #include #include // ENQUEUE(Q, x) // Q... 阅读全文
posted @ 2015-02-11 17:04 孙永杰 阅读(217) 评论(0) 推荐(0) 编辑
摘要:1 /* 2 * IA_10.1_stack.h 3 * 4 * Created on: Feb 13, 2015 5 * Author: sunyj 6 */ 7 8 #ifndef IA_10_1_STACK_H_ 9 #define IA_10_1_STACK_H_1... 阅读全文
posted @ 2015-02-11 15:23 孙永杰 阅读(261) 评论(0) 推荐(0) 编辑
摘要:使用信号捕抓ctrl + c信号/* * 1.10ReadCommandsFromStandardInputAndExecuteThem.cpp * * Created on: Feb 11, 2015 * Author: sunyj */ #include "../apuesunyj.h" #include static void sig_int(int); // o... 阅读全文
posted @ 2015-02-11 13:33 孙永杰 阅读(174) 评论(0) 推荐(0) 编辑
摘要:// 以下摘自网络静态函数在函数的返回类型前加上关键字static,函数就被定义成为静态函数。函数的定义和声明默认情况下是extern的,但静态函数只是在声明他的文件当中可见,不能被其他文件所用。定义静态函数的好处: 其他文件中可以定义相同名字的函数,不会发生冲突 静态函数不能被其他文件所用。 存储... 阅读全文
posted @ 2015-02-11 12:41 孙永杰 阅读(1075) 评论(1) 推荐(0) 编辑
摘要:/* * 1.8DemonstrateStrerrorAndPerror.cpp * * Created on: Feb 11, 2015 * Author: sunyj */ #include "../apuesunyj.h" int main(int argc, char *argv[]) { fprintf(stderr, "EACCES: %s\n", stre... 阅读全文
posted @ 2015-02-11 11:10 孙永杰 阅读(328) 评论(0) 推荐(0) 编辑
摘要:// apuesunyj.h #ifndef APUE_SUNYJ #define APUE_SUNYJ #include #include #include #include #include #include #include int64_t const MAXLINE = 4096; // max line length int64_t const ARG_MAX = 40... 阅读全文
posted @ 2015-02-11 10:34 孙永杰 阅读(292) 评论(0) 推荐(0) 编辑
摘要:/* * 1.7ReadCommandsFromStandardInputAndExecuteThem.cpp * * Created on: Feb 11, 2015 * Author: sunyj */ #include #include "../apuesunyj.h" int main() { char buf[MAXLINE]; pid_t... 阅读全文
posted @ 2015-02-11 10:28 孙永杰 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2015-02-11 10:20 孙永杰 阅读(240) 评论(0) 推荐(0) 编辑
摘要:under the directory of the project, create file .gdbinitwrite the "set follow-fork-mode child"then you can debug the child process 阅读全文
posted @ 2015-02-11 09:53 孙永杰 阅读(332) 评论(0) 推荐(0) 编辑
摘要:1 /* 2 * 1.6PrintTheProcessID.cpp 3 * 4 * Created on: Feb 11, 2015 5 * Author: sunyj 6 */ 7 8 #include "../apuesunyj.h" 9 10 int main(void) 11 { 12 printf("hello wo... 阅读全文
posted @ 2015-02-11 08:43 孙永杰 阅读(266) 评论(0) 推荐(0) 编辑
摘要:/* * 1.5CopyStandardInputToStandardOutputUsingStandardIO.cpp * * Created on: Feb 10, 2015 * Author: sunyj */ #include "../apuesunyj.h" /* The standard I/O functions provide a buffered... 阅读全文
posted @ 2015-02-10 20:55 孙永杰 阅读(188) 评论(0) 推荐(0) 编辑
摘要:// 1.4CopyStandardInputToStandardOutput.cpp #include "../apuesunyj.h" #define BUFFSIZE 4096 int main() { int n; char buf[BUFFSIZE]; // By convention, all shells open three descriptors ... 阅读全文
posted @ 2015-02-10 19:55 孙永杰 阅读(300) 评论(0) 推荐(0) 编辑
摘要:// 1.3ListAllTheFilesInADirectory.cpp#include #include "../apuesunyj.h"int main(int argc, char *argv[]){ DIR* dp; struct dirent* dirp; if (2 != argc) ... 阅读全文
posted @ 2015-02-10 19:10 孙永杰 阅读(229) 评论(0) 推荐(0) 编辑
摘要:// apuesunyj.h#ifndef APUE_SUNYJ#define APUE_SUNYJ#include #include #include #include #include #include void err_quit(const char *fmt, ...);void err_s... 阅读全文
posted @ 2015-02-10 17:46 孙永杰 阅读(203) 评论(0) 推荐(0) 编辑
摘要:将所有/etc/yum.repos.d/下面的文件,中https更改为http,避免yum问题sudo yum -y install vnc-server 阅读全文
posted @ 2015-02-10 13:59 孙永杰 阅读(115) 评论(0) 推荐(0) 编辑
摘要:#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 孙永杰 阅读(676) 评论(1) 推荐(0) 编辑
摘要:以下摘自网络 随机化快排:快速排序的最坏情况基于每次划分对主元的选择。基本的快速排序选取第一个元素作为主元。这样在数组已经有序的情况下,每次划分将得到最坏的结果。一种比较常见的优化方法是随机化算法,即随机选取一个元素作为主元。这种情况下虽然最坏情况仍然是O(n^2),但最坏情况不再依赖于输入数据,而是由于随机函数取值不佳。实际上,随机化快速排序得到理论最坏情况的可能性仅为1/(2^n)。所以随机化... 阅读全文
posted @ 2015-02-10 10:00 孙永杰 阅读(521) 评论(0) 推荐(0) 编辑
摘要:不说狠话,不做软事 阅读全文
posted @ 2015-02-09 21:12 孙永杰 阅读(479) 评论(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 孙永杰 阅读(286) 评论(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 孙永杰 阅读(453) 评论(0) 推荐(0) 编辑
摘要:svn ci失败, 考虑使用 svn del --force 来删除有问题的目录和文件,不行的话再使用svn resolve --accept=working LinerTimeMaxSubarray(提示有冲突的文件或者目录)svn cleanup就应该可以解决了 阅读全文
posted @ 2015-02-09 15:17 孙永杰 阅读(314) 评论(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 孙永杰 阅读(229) 评论(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 孙永杰 阅读(279) 评论(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 孙永杰 阅读(231) 评论(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 孙永杰 阅读(465) 评论(0) 推荐(0) 编辑
摘要:// threads/exitstatus.c 11-2 #include "apue.h" #include void* thr_fn1(void* arg) { printf("thread 1 returning\n"); /* return a variable of type void* return a pointer who points ... 阅读全文
posted @ 2015-02-06 21:59 孙永杰 阅读(264) 评论(0) 推荐(0) 编辑
摘要:程序清单11-1打印线程ID// threads/threadid.c 11-1 #include "apue.h" #include pthread_t ntid; void printids(const char* s) { printf("%d ", (unsigned int)ntid); printf("%ld ", (uns... 阅读全文
posted @ 2015-02-06 21:30 孙永杰 阅读(200) 评论(0) 推荐(0) 编辑
摘要:// signals/sigusr.c 10-1 #include "apue.h" static void sig_usr(int); /* one handler for both signals */ int main(void) { if (signal... 阅读全文
posted @ 2015-02-06 18:53 孙永杰 阅读(262) 评论(0) 推荐(0) 编辑
摘要:// proc/exec1.c 8-8 #include "apue.h" #include const char* env_init[] = { "USER=unknown", "PATH=/home/sunyj/apue/proc/", NULL }; int main(void) { pid_t pid; if ((pid = ... 阅读全文
posted @ 2015-02-06 16:05 孙永杰 阅读(284) 评论(0) 推荐(0) 编辑
摘要:这一节,书中的TELL_WAIT与TELL_PARENT,TELL_CHILD没有弄清楚,到底是如何实现的同步机制。 // proc/tellwait1.c 8-6 #include "apue.h" static void charatatime(const char *); int main(void) { pid_t pid; if ((pid = fork()... 阅读全文
posted @ 2015-02-06 13:13 孙永杰 阅读(263) 评论(0) 推荐(0) 编辑
摘要:我的博客主题,css 阅读全文
posted @ 2015-02-06 09:59 孙永杰 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2015-02-04 20:57 孙永杰 阅读(140) 评论(0) 推荐(0) 编辑
摘要:快速排序 1 #include 2 #include 3 // QUICKSORT(A, p, r) 4 // if p 63 #include "7.1_quicksort.h"64 65 int main()66 {67 int64_t array[] = { 2, 8, 7, 1,... 阅读全文
posted @ 2015-02-03 21:10 孙永杰 阅读(179) 评论(0) 推荐(0) 编辑
摘要:heap// heap.h // PARENT(i) // return i / 2 // LEFT(i) // return 2 * i // RIGHT(i) // return 2 * i + 1 // MAX-HEAP... 阅读全文
posted @ 2015-02-03 21:07 孙永杰 阅读(542) 评论(0) 推荐(0) 编辑
摘要:strassen// strassen.h#ifndef STRASSEN_HH#define STRASSEN_HH#include #include templateclass Strassen_class{public: void ADD(T** MatrixA, T** MatrixB... 阅读全文
posted @ 2015-02-03 21:01 孙永杰 阅读(443) 评论(0) 推荐(0) 编辑
摘要:// liner_time_max_subarray.cpp#include #include int my_sum(int const * p, int const n, int & begin, int & end){ int max; int sum; int max_all... 阅读全文
posted @ 2015-02-03 20:59 孙永杰 阅读(242) 评论(0) 推荐(0) 编辑
摘要:寻找最大子数组// find_max_sub_array.h #include int Find_MAX_CROSSING_SUBARRAY(int* A, int low, int mid, int high, int& max_left, int& max_right, in... 阅读全文
posted @ 2015-02-03 20:53 孙永杰 阅读(193) 评论(0) 推荐(0) 编辑
摘要:// 2.3.1 merge.h #include // MERGE(A, p, q, r) // n1 = q - p + 1 // n2 = r - q // let L[1..n1 + 1] and R[1..n2 + 1] be new arrays // for i = 1 to n1 // L[i] = A[p + i - 1] // for j = 1 to n2 // ... 阅读全文
posted @ 2015-02-03 20:48 孙永杰 阅读(358) 评论(0) 推荐(0) 编辑
摘要:插入排序// insertion_sort.h not with template #include #include // INSERTION-SORT(A) // for j = 2 to A.length // key = A[j] // ... 阅读全文
posted @ 2015-02-03 20:32 孙永杰 阅读(376) 评论(0) 推荐(0) 编辑
摘要:自动生成了,src和Debug文件夹将已经存在的代码目录源文件拷到src下,eclipse会自动分析并加入工程,将原来的该注释的函数注释掉,开始的时候我们新建工程时,选的是新的helloworld工程模版includelink g++ -rdynamic -lpthread -lc -lnsl -l... 阅读全文
posted @ 2015-02-03 11:56 孙永杰 阅读(327) 评论(0) 推荐(0) 编辑
摘要:when install centos eclipse when install the os system, the cdt is already installed, but some time when you first start the eclipse, you can not find 阅读全文
posted @ 2015-02-03 09:28 孙永杰 阅读(123) 评论(0) 推荐(0) 编辑
摘要:orilink:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310489d2d0e54f73c6bca814623928448e53919161b71e3cd73794e53c4c50a3152e91a4bea8677366b14... 阅读全文
posted @ 2015-02-03 08:59 孙永杰 阅读(514) 评论(0) 推荐(0) 编辑
摘要:知行网www.zhixing123.cn 编辑:麦田守望者git命令的安装与github简单使用时间:2013-09-25 01:51来源:知行网www.zhixing123.cn 编辑:麦田守望者git的出现让传统的svn陷入尴尬的境地,分布式的版本控制是局势所需,svn目前也称要支持分布式,但至... 阅读全文
posted @ 2015-02-03 06:43 孙永杰 阅读(296) 评论(0) 推荐(0) 编辑
摘要:zhoulf 2013-02-02 原创ori page:http://www.cnblogs.com/zhoulf/archive/2013/02/02/2889949.html安装说明系统环境:CentOS-6.3 安装方式:yum install (源码安装容易产生版本兼容的问题)安装软件:系... 阅读全文
posted @ 2015-02-02 22:14 孙永杰 阅读(109) 评论(0) 推荐(0) 编辑
摘要:http://www.cnblogs.com/rubylouvre/archive/2013/01/24/2874694.html 阅读全文
posted @ 2015-02-01 12:59 孙永杰 阅读(128) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示