自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 资源 (6)
  • 收藏
  • 关注

原创 linux C执行命令并保存到string中

#include #include #include "cmd_exec.h"#include "comm.h"string ExecCmd(const string & cmd){ char store[kPipeMax], command[kCmdMax]; string result; StrToCharStar(cmd, command);

2011-06-17 09:58:00 804

原创 C语言分配与回收二维数组

#include #include #include void getMem(int **&p, int m, int n){ int i; p = (int **)malloc(m*(sizeof(int *))); for (i = 0; i < m; ++i) { p[i] = (int *)malloc(n*(sizeof(int))); }}

2011-06-17 09:57:00 1078

原创 防止僵尸进程的代码

void sigchld_handler(int sig){ while (waitpid(-1, 0, WNOHANG) > 0) ; return;}int main(){ signal(SIGCHLD, sigchld_handler); while (1) { connfd = accept(listenfd, (SA*) &client

2011-06-17 09:56:00 593

原创 VC读取目录下所有文件名

#include #include #include #include const int kMaxNum = 256; // 最大文件个数const int kMaxLength = 20; // 文件名的最大长度char fileName[kMaxNum][kMaxLength];int fileNum = 0; // 文件个数-1// 获取目录文件

2011-06-17 09:55:00 2816 2

原创 求重叠区间

/*用c语言完成函数 size_t foo(unsigned int *a1, size_t al1, unsigned int* a2, size_t al2)悬赏分:10 | 离问题结束还有 14 天 23 小时 | 提问者:龙潇九声 | 检举其中a1 和a2 都为无符号数组,al1 和al2 为数组的长度,数组的长度为偶数。无符号数组由一对数字区间组成。如下例:a1 为

2011-06-17 09:54:00 770

原创 求方差

#include #include using namespace std;double Variance(int * d, int n); // 方差int main(){ int a[5] = {4, 5, 7, 9, 10}; printf("%6.3f/n", Variance(a, 5)); return 0;}double Var

2011-06-17 09:54:00 680

原创 二进制文件拷贝

/*文件操作要求:将文件 in.exe 复制为名为 out.exe文件请在int main()函数里面编辑*/#include #include #include int filesize(FILE *stream);void BinaryFileCopy(const char * src_file_name, const char * dst_fi

2011-06-17 09:54:00 985 1

原创 C操作mysql

#include #include int main(){ MYSQL mysql; // need a instance to init MYSQL_RES *res; MYSQL_ROW row; char *query; int t,r; mysql_init(&mysql); if(!mysql_

2011-06-17 09:53:00 360

原创 Linux下hash_map之类

#include #include #include #include #include using namespace std;/*#include using namespace __gnu_cxx;struct str_hash{ size_t operator()(const string& str) const { unsigne

2011-06-17 09:52:00 499

原创 boost图库简单操作

#include #include #include using namespace boost;#include // for std::cout#include // for std::pair#include // for std::for_eachusing namespace std;#include int main(int,cha

2011-06-17 09:51:00 1170 1

原创 查看截获的信号

#include #include #include #include #include using namespace std;void handler(int sig_no){ printf("signal [%d]/n", sig_no);}int main(){ int i; for (i = 0; i < 64; ++i) {

2011-06-17 09:51:00 476

原创 gethostbyname

#include #include #include #include int main(int argc, char **argv){ char *ptr,**pptr; struct hostent *hptr; char str[32]; /* 取得命令后第一个参数,即要解析的域名或主机名 */ ptr = argv[1]; /* 调用geth

2011-06-17 09:50:00 395

原创 LCS实现

#include #include #include #define MAX 1000char str1[MAX+1], str2[MAX+1];// int mem[MAX+1][MAX+1];int max(int a, int b){ return a > b ? a : b;}// recursive/* int Lcs(char * s

2011-06-17 09:49:00 452

原创 备忘录和递归解决背包问题

#include #include int n, M;#define MAX 3407#define MMAX 12880int w[MAX+1];int d[MAX+1];int mem[MAX+1][MMAX+1];int Max(int a, int b){ return a > b ? a : b;}// 考虑index为n的

2011-06-17 09:48:00 1260

原创 矩阵连乘分别用备忘录递归和动态规划解决

#include #include int main(void){ clock_t start, end; long i, j = 1; start = clock(); for( i = 0; i <= 1000000000; ++i ) { j *= 1024 * 1024 * 1024; j /= 1024 * 1024 * 1024; }

2011-06-17 09:47:00 740

原创 移位和乘2效率

#include #include int main(void){ clock_t start, end; long i, j = 1; start = clock(); for( i = 0; i <= 1000000000; ++i ) { j *= 1024 * 1024 * 1024; j /= 1024 * 1024 * 1024; }

2011-06-17 09:46:00 821

原创 各排序算法实现

#include void Input(int *a, int n) { int i; for (i = 0; i < n; ++i) { scanf("%d", &a[i]); }}void Output(int * a, int n) { int i; for (i = 0; i < n; ++i) { printf("%4d", a

2011-06-16 15:01:00 437

转载 教你摆脱人人桌面renrenservice.exe启动的困扰

用人人桌面的朋友都知道,经常会自动启动人人桌面就算你将它从启动项中移除过几天又会莫名其妙的出现了。这个都是renrenservice.exe惹的祸,只要处理掉一切事故就都解决了。本人是有个毛病不喜欢垃圾进程占用我的内存,我都会想尽一切方法摆平它。方法如下很简单(使用多用户登陆的朋友最好不要出去这个进程,否者将无法开启2个或2个以上的人人桌面了) 打开任务管理器在进程中找到renrenservice

2011-06-06 08:56:00 4434

原创 VS2010下安装boost库

1.去www.boost.org下载最新的boost,我下载了boost_1_46_1.7z2.(我放在D:/cpp目录下)解压到当前文件夹3.打开VS2010->VS TOOLS->VS命令提示4.CD D:/cpp/boost_1_46_1  5.输入bootstrap,便生成bjam.exe文件6.输入bjam toolset=msvc-10.0 variant=debu

2011-06-05 12:46:00 6363 2

原创 windows和linux在控制台下读取EOF的问题

测试程序的代码如下:#include int main(){ char ch; while (ch = getchar()) { if (ch == '/n') continue; if (ch == EOF) { printf("EOF/n"); } else { printf("%c/n", ch); } } return 0;}1.在Windows下采用vs2010编译,运行情况如下:ctrl+z 回车  打印EOF且

2011-05-24 20:21:00 1109

Linux C 编程一站式学习

该书介绍了C语言,以及Linux下的C编程,从底层分析起,是一本不错的书。

2011-02-22

GCC中文手册-选项及使用

本书用中文详细介绍GCC的各种命令参数以及用法,欢迎下载使用。

2011-02-22

C程序设计题解与上机指导

C程序设计题解与上机指导 谭浩强 清华大学出版社 是C程序设计的辅助材料。

2011-02-22

汇编语言--王爽(清华大学出版社)

是汇编语言入门的一本经典书籍,欢迎大家下载。

2011-01-23

程序员的编辑器--VIM

详细介绍VIM的使用方法,有一些高级的用法,同时提供一些插件的使用链接,欢迎大家下载。

2011-01-23

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除