- 博客(22)
- 资源 (3)
- 收藏
- 关注
转载 select
出自http://blog.csdn.net/lianghe_work/article/details/46506143test.c#include #include #include #include #include #include int main(int argc,char** argv){if(argc != 2){print
2018-01-29 16:43:29 106
转载 判断本机是大端还是小端
#include int main(int argc,char** argv){unsigned int a = 0x12345678;unsigned char* p = (unsigned char*)&a;if(0x12 == *p){printf("big endian\n");}else if(0x78 == *p){printf("l
2018-01-26 20:25:27 370
转载 port
“端口”是 0 到 65535 之间的一个整数,正好 16 个二进制位。0到 1023 的端口被系统占用,用户只能选用大于 1023 的端口。不管是浏览网页还是在线聊天,应用程序会随机选用一个端口,然后与服务器的相应端口联系。“传输层”的功能,就是建立“端口到端口”的通信。相比之下,“网络层”的功能是建立“主机到主机”的通信。
2018-01-26 17:55:53 193
转载 frame
传输层叫segment/datagram网络层叫packet数据链路层叫frame不同的数据链路层协议对应着不同的帧,所以,帧有多种,比如PPP帧、MAC帧等下面以MAC帧的格式为例进行说明:MAC帧的帧头包括三个字段。前两个字段分别为6字节长的目的地址字段和源地址字段(因为mac地址是48位),目的地址字段包含目的MAC地址信息,源地址
2018-01-26 10:58:57 252
转载 upd报文
数据报的长度是指包括报头和数据部分在内的总字节数。因为报头的长度是固定的,所以该域主要被用来计算可变长度的数据部分(又称为数据负载)。数据报的最大长度根据操作环境的不同而各异。从理论上说,包含报头在内的数据报的最大长度为65535字节。不过,一些实际应用往往会限制数据报的大小,有时会降低到8192字节。UDP首部中校验和的计算方法有些特殊。在计算校验和时,要在UDP用户数据报之前增
2018-01-25 17:06:45 874
转载 tcp报文头
http://blog.csdn.net/a19881029/article/details/29557837TCP(Transmission Control Protocol)传输控制协议是一种面向连接的、可靠的、基于字节流的传输层协议TCP报文格式:源端口号(2字节): d5 df(54751)目的端口号(2字节):
2018-01-25 11:37:55 805
转载 ip报文头
出处 https://www.cnblogs.com/xiehy/archive/2013/07/02/3166953.htmlIP数据包也叫IP报文分组,传输在ISO网络7层结构中的网络层,它由IP报文头和IP报文用户数据组成,IP报文头的长度一般在20到60个字节之间,而一个IP分组的最大长度则不能超过65535个字节。 下图为IP分组的报文头格式,报文头的前20个字节
2018-01-24 20:16:19 3726 1
转载 unix domain socket实现同一主机不同进程间通信
原文 https://www.cnblogs.com/chekliang/p/3222950.htmlsocket API原本是为网络通讯设计的,但后来在socket的框架上发展出一种IPC机制,就是UNIX Domain Socket。虽然网络socket也可用于同一台主机的进程间通讯(通过loopback地址127.0.0.1),但是UNIX Domain Socket用于
2018-01-22 12:29:24 3801
转载 socket
原文https://www.cnblogs.com/skynet/archive/2010/12/12/1903949.html因为in.h中包含了sys/socket.h,所以就不用include了 server.c#include #include #include #include #include #include #define MAXLINE 4
2018-01-18 11:46:30 285
转载 pthread_mutex_t,pthread_cond_wait
http://www.360doc.com/content/10/1008/23/3700464_59462698.shtmlhttp://weihe6666.iteye.com/blog/1170141http://tower.iteye.com/blog/3092941 wait线程中应用while,将pthread_cond_wait包裹2 pthread_cond_
2018-01-17 11:37:05 234
原创 二叉搜索树
1、定义左孩子的值都比自己小,右孩子的值都比自己大2、搜索伪代码如下BST_Search(root,x)输入:root(指向二叉搜索树的根节点)以及x(待搜索的某数)输出:node(指向值为x的节点的指针,如果没有值为x的节点,则为nil)beginif(root == nil || root.key == x){return root;}else{if
2018-01-13 10:40:59 127
原创 select_sort
#includevoid printArray(int* array,int length){for(int i = 0;i printf("the index is %d,the value is %d\n",i,array[i]);}}// 选择排序// 基本思想/*每一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置,直到全部待排序
2018-01-13 10:36:13 331
原创 quick_sort(pivot is left)
#include<stdio.h>void printArray(int* array,int length){for(int i = 0;i < length;i++){printf("the index is %d,the value is %d\n",i,array[i]);}}// left和right分别是array数组的左、右元素的下标。// 函数返回值...
2018-01-13 10:35:49 204
原创 merge_sort
#includevoid printArray(int* array,int length){for(int i = 0;i printf("the index is %d,the value is %d\n",i,array[i]);}}// 归并排序void mergeSort(int* array,int left,int right){int middle;
2018-01-13 10:34:58 125
原创 insert_sort
#includevoid printArray(int* array,int length){for(int i = 0;i printf("the index is %d,the value is %d\n",i,array[i]);}}// 直接插入排序// 基本思想/*有一个已经有序的数据序列,要求在这个已经排好的数据序列中插入一个数,但要求插入后此数据序
2018-01-13 10:34:17 183
原创 huffman
#include #include #include // 哈夫曼树/*比如有a,b,c,d,e五个字符,它们出现的频率(即权值)分别为(5,4,3,2,1)那么先取权值最小的两个来构造一个子树,左孩子是1,右孩子是2,父节点是这两个孩子的权值之和3那么现在集合中的数为(5,4,3,3)再取两个最小的来构造另一个子树,左孩子是3,右孩子也是3,父节点是6那么现在
2018-01-13 10:33:47 447
原创 heap_sort
#includevoid printArray(int* array,int length){for(int i = 0;i printf("the index is %d,the value is %d\n",i,array[i]);}}// 堆排序/*是选择排序的一种,分为大根堆和小根堆,是完全二叉树。大根堆的要求是每个节点的值都不大于其父节点的值。在数组的
2018-01-13 10:33:14 120
原创 bubblesort
// 冒泡排序#includevoid bubblesort(int* array,int length){int i,j;for(i = 0;i for(j = 0;j if(array[j] > array[j + 1]){int temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;}
2018-01-13 10:29:30 161
原创 binarysearch
// 折半查找#includeint binarySearch(int x,int* array,int left,int right){// 在有序数组array的left至right范围内查找x,并返回x在数组中的下标,如果没有找到,则返回-1if(left > right){printf("the left is larger than right,error\n");r
2018-01-13 10:27:38 126
支持java8的proguard
2018-06-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人