自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 资源 (2)
  • 收藏
  • 关注

原创 翻转句子中单词的顺序 C语言

C语言 字符串 算法

2014-08-10 15:55:55 10198

原创 逆转字符串 C语言

#include #include char* Reverse(char *str) { if(str == NULL) return str; char *pLast = str + (strlen(str) - 1); char *pBegin = str; while(pBegin != pLast) {

2014-08-09 17:39:52 2605

原创 位图算法 C语言

位图算法 C语言

2014-08-06 00:17:05 2904

原创 C语言反转单链表

反转单链表 定义一个函数,输入一个链表的头结点,反转该链表并输出反转后链表的头结点。

2014-07-22 17:10:57 22929 1

原创 用条件变量实现阻塞队列

#include #include #include const int NUM = 20;  struct node {     int val;     struct node *next; }; void node_ini(struct node *n, int i) {     n->val = i;     n->next = NULL; }

2014-07-18 17:19:41 910

原创 fedora 20下安装vim的C++补全插件clang_complete

fedora 20下安装vim的C++补全插件clang_complete

2014-07-13 16:38:53 2352

原创 递归合并有序链表C语言

递归逆转链表和递归合并有序链表的代码

2014-07-11 14:58:52 2419

原创 快速排序代码

#include #include #include void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; } int partition(int a[], int nLeft, int nRight) { int v = a[nRight]; int i = nLeft - 1;

2014-06-06 14:53:26 690

原创 Linux设备驱动程序代码 第2章 建立和运行模块

第2章 建立和运行模块 1.资源下载 电子书地址: pdf版: http://www.kuaipan.cn/file/id_12008874588517353.htm chm版: http://www.kuaipan.cn/file/id_12008874588517352.htm 源码: http://www.kuaipan.cn/file/id_12

2012-12-16 15:12:05 1235 2

原创 Unix网络编程代码 第28章 原始套接字

第28章 原始套接字 28.5 ping程序 #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #incl

2012-01-18 20:16:18 2487

原创 Unix网络编程代码 第30章 客户/服务器程序设计范式

第30章 客户/服务器程序设计范式 30.3 TCP测试用客户程序 运行:./client 127.0.0.1 8888 1 5000 4000 #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #inc

2012-01-17 01:04:02 1663

原创 Unix网络编程代码 第20章 广播

第20章 广播 20.4 使用广播的dg_cli函数 //运行前启动daytime服务,运行:./client 192.168.1.255,启动后,随便输入字符 #include /* sockaddr_in{} and other Internet defns */ #include #include #include #include #include #include #i

2012-01-13 23:58:28 663

原创 Unix网络编程代码 第17章 ioctl操作

第17章 ioctl操作 17.6 get_ifi_info函数 #define _GNU_SOURCE #include /* sockaddr_in{} and other Internet defns */ #include /* ANSI C header file */ #include #include #include #include #include #incl

2012-01-13 18:00:51 1314

原创 Unix网络编程代码 第16章 非阻塞式I/O

第16章 非阻塞式I/O 16.2 非阻塞读和写:str_cli函数(修订版) //使用select #include /* sockaddr_in{} and other Internet defns */ #include #include /* ANSI C header file */ #include /* for syslog() */ #include #include

2012-01-13 16:34:41 1027

原创 Unix网络编程代码 第14章 高级I/O函数

第14章 高级I/O函数 14.2 套接字超时 14.2.1 使用SIGALRM 为连接设置超时 #include /* sockaddr_in{} and other Internet defns */ #include #include /* ANSI C header file */ #include /* for syslog() */ #include #include

2012-01-12 23:16:59 742

原创 Unix网络编程代码 第13章 守护进程和inetd超级服务器

第13章 守护进程和inetd超级服务器 13.4 daemon_init函数 13.4.1 作为守护进程运行的协议无关时间获取服务器程序 运行: ./server localhost daytime 查看日志: tail /var/log/syslog #define _POSIX_SOURCE #include #include #include /* basic socket

2012-01-12 20:38:08 1138

原创 Unix网络编程代码 第11章 名字与地址转换

第11章 名字与地址转换 11.3 gethostbyname函数 #define _BSD_SOURCE #include #include #include #include #include #include #include #define MAXLINE 4096 /* max text line length */ void err_doit(int errnofl

2012-01-12 15:17:21 671

原创 Unix网络编程代码 第8章 基本UDP套接字编程

第8章 基本UDP套接字编程 8.3 UDP回射服务器程序 #include /* sockaddr_in{} and other Internet defns */ #include #include #include #include #include #include /* ANSI C header file */ #define MAXLINE 4096 /* max

2012-01-12 01:55:04 997

原创 Unix网络编程代码 第7章 套接字选项

第7章 套接字选项 7.3 检查选项是否受支持并获取默认值 #define __need_timeval #include #include #include /* for TCP_xxx defines */ #include #include /* sockaddr_in{} and other Internet defns */ #include #include #in

2012-01-11 23:11:13 1036

原创 Unix网络编程代码 第6章 I/O复用:select、poll和epoll函数

第6章 I/O复用:select、poll和epoll函数 6.4 str_cli函数(修订版) //使用select #define _POSIX_SOURCE #include /* sockaddr_in{} and other Internet defns */ #include #include #include /* ANSI C header file */ #inclu

2012-01-11 19:39:08 1154

原创 Unix网络编程代码 第5章 TCP客户/服务器程序示例

第3章 套接字编程简介 3.4 字节排序函数 #include #include #define CPU_VENDOR_OS "i686-pc-linux-gnu" int main(int argc, char **argv) { union { short s; char c[sizeof(short)]; } un; un.s = 0x0102; pri

2012-01-10 01:18:16 1433 3

原创 Unix网络编程代码 第1章 简介

1.2 一个简单的时间获取客户程序 #include /* sockaddr_in{} and other Internet defns */ #include #include /* ANSI C header file */ #include /* for syslog() */ #include #include #include #include #include

2012-01-08 21:35:59 764

原创 算法导论代码 第25章 每对顶点间的最短路径

第25章 每对顶点间的最短路径 25.1 最短路径与矩阵乘法 #include #include #include #include typedef struct graph_type *graph; struct edge { int u; int v; int w; }; struct vertex { char str_vertex[256]; //顶点的字符串表示,

2011-12-31 11:37:50 1193

原创 算法导论代码 第24章 单源最源路径

第24章 单源最源路径 24.1 Bellman-Ford算法 #include #include #include #include #include typedef struct graph_type *graph; struct edge { int u; int v; int w; }; struct graph_node { int key; int w; st

2011-12-30 19:03:49 990

原创 算法导论代码 第23章 最小生成树

第23章 最小生成树 22.2 Kruskal算法和Prim算法 22.2.1 Kruskal算法 #include #include #include #include typedef struct graph_type *graph; struct edge { int u; int v; int w; }; struct graph_node { int key; i

2011-12-30 18:54:03 1068

原创 算法导论代码 第22章 图的基本算法

第22章 图的基本算法 22.1 图的表示 22.1.1 邻接表表示法 #include #include #include typedef struct graph_type *graph; struct edge { int u; int v; }; struct graph_node { int key; struct graph_node *next; }; void

2011-12-30 18:45:27 1060

原创 算法导论代码 第21章 用于不相交集合的数据结构

第21章 用于不相交集合的数据结构 21.2 不相交集体的链表表示 #include #include #include typedef struct set_type *set; struct set_node { void *key; struct set_node *next; struct set_node *representative; //指向代表的集合元素 };

2011-12-30 18:10:05 1014

原创 算法导论代码 第20章 斐波那契堆

第20章 斐波那契堆 #include #include #include #include #include #include typedef struct fib_heap *heap; struct heap_node { void *key; int degree; bool mark; struct heap_node *child; struct heap_no

2011-12-30 18:07:28 1041

原创 算法导论代码 第19章 二项堆

第19章 二项堆 #include #include #include #include #include typedef struct binomial_heap *heap; struct heap_node { void *key; int degree; struct heap_node *child; struct heap_node *sibling; struc

2011-12-30 18:06:15 834

原创 算法导论代码 第18章 B树

第18章 B树 #include #include #include #include #include /*两个约定:(1)B树的根结点始终在主存中,因而无需对根做DISK_READ, 但是根结点被改变后,都需要对根结点做一次DISK_WRITE (2)任何被当作参数的结点被传递之前,要先对它们做一次DISK_READ*/ #define DISK_READ(x) #define

2011-12-30 18:04:20 1207

原创 算法导论代码 第16章 贪心算法

第16章 贪心算法 16.1 活动选择问题 #include void recursive_activity_select(int s[], int f[], int i, int j, int select_set[], int *select_num) { int m = i + 1; while (m < j && s[m] < f[i]) { ++m; }

2011-12-30 16:57:05 812

原创 算法导论代码 第15章 动态规划

第15章 动态规划 15.1 装配线调度 #include #include enum { NUM = 6 }; void fastest_way(int n,int a[][n], int t[][n - 1], int e[], int x[], int f[][n], int l[][n], int *fastest_time, int *last_line) { f[

2011-12-30 16:53:35 976

原创 算法导论代码 第14章 数据结构的扩张

第14章 数据结构的扩张 14.1 动态顺序统计 #include #include #include typedef struct red_black_tree_type *tree; enum color_enum { color_red, color_black }; struct tree_node { void *key; enum color_enum color;

2011-12-30 16:02:15 648

原创 算法导论代码 第13章 红黑树

#include #include #include typedef struct red_black_tree_type *tree; enum color_enum { color_red, color_black }; struct tree_node { void *key; enum color_enum color; struct tree_node *parent;

2011-12-30 15:59:26 1310

原创 算法导论代码 第12章 二叉查找树

第12章 二叉查找树 #include #include #include typedef struct binary_search_tree_type *tree; struct tree_node { void *key; struct tree_node *parent; struct tree_node *left; struct tree_node *right;

2011-12-30 15:57:23 490

原创 算法导论代码 第11章 散列表

第11章 散列表 11.2 散列表 #include #include /*通过链接法解决碰撞*/ typedef struct hash_chain_type *hash; typedef struct list_type *list; struct list_node { void *key; struct list_node *prev; struct list_node *n

2011-12-30 15:55:12 628

原创 算法导论代码 第10章 基本数据结构

第10章 基本数据结构 10.1 栈和队列 10.1.1 栈 10.1.1.1 基于数组实现 #include #include #include typedef struct stack_type *stack; struct stack_type { int top; int num; void **array; }; stack stack_create(int num)

2011-12-30 15:53:03 573

原创 算法导论代码 第9章 中位数和顺序统计学

第9章 中位数和顺序统计学 9.1 最小值和最大值 #include #include #include #include int minimum(int A[], int n) { int min = A[0]; for (int i = 1; i < n; i++) { if (min > A[i]) { min = A[i]; } } return mi

2011-12-30 15:48:39 599

原创 算法导论代码 第8章 线性时间排序

第8章 线性时间排序 8.2 计数排序 #include #include #include #include void counting_sort(int A[], int n, int k) { int *C = malloc(sizeof(int) * (k + 1)); for (int i = 0; i <= k; i++) { C[i] = 0; } for

2011-12-30 15:30:06 575

原创 算法导论代码 第7章 快速排序

第7章 快速排序 7.1 快速排序的描述 #include #include #include #include void swap(void *a, void *b, size_t elem_size) { if(a==NULL||b==NULL||a==b) return; char temp[elem_size]; /*变长数组 */ memcpy(temp, a, e

2011-12-30 15:20:01 549

算法导论的代码C++版

算法导论的代码C++版,自己实现的,可以供参考

2011-08-30

空空如也

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

TA关注的人

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