摘要: 不同的链路层协议:以太网、令牌环网、F D D I(光纤分布式数据接口)及R S-2 3 2串行线路等------------------------------A R P和R A R P协议对32 bit的I P地址和48 bit的硬件地址进行映射。------------------------------------------------------------8 0 2 . 3规定数据部分必须至少为3 8字节,而对于以太网,则要求最少要有4 6字节------------------------------SLIP报文的封装1:首位都加oxc02:如果数据中有oxc0,已db dc代 阅读全文
posted @ 2011-09-07 02:12 lifengzhong 阅读(148) 评论(0) 推荐(0) 编辑
摘要: TCP数据单元:tcp segmentUDP数据单元:udp datagramIP数据单元:IP datagram链路层单元:frame---------------------------------------应用层:SMTP:简单邮件传输协议FTP:文件传输协议DNS:域名系统传输层:TCP:控制传输协议UDP:用户数据报协议网络层:ICMP:Internet 控制报文协议IGMP:Internet 组管理协议IP:网际协议链路层:Enthernet:以太网ARP:地址解析协议RARP:逆地址解析协议-------------------------------------------- 阅读全文
posted @ 2011-09-07 01:51 lifengzhong 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 编程之美3.8-求二叉树中节点最大距离编程之美3.10分层遍历二叉树View Code #include <iostream>#include <vector>#include <cstring>#include "general.h"//编程之美3.8-求二叉树中节点最大距离-递归int getMaxDepth(CPTNODE pNode) //求最大深度{ if (pNode == NULL) { return -1; } return 1 + MAX(getMaxDepth(pNode->left), getMaxDepth( 阅读全文
posted @ 2011-09-06 10:28 lifengzhong 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 鞭惩之美-3.3计算字符串相似度鞭惩之美-3.4无头单链删除节点鞭惩之美-3.9重建二茶树View Code 1 #include <iostream> 2 #include <cstring> 3 #include "general.h" 4 5 //鞭惩之美-3.3计算字符串相似度 6 int stepCount(const char* preArray, int preSize, const char* postArray, int postSize) 7 { 8 if (!preSize || !postSize) { 9 return pr 阅读全文
posted @ 2011-09-05 14:58 lifengzhong 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 样例代码共用头文件general.h包含常用头文件,数据结构定义及全局函数。View Code #ifndef _GENERAL_H_#define _GENERAL_H_#define MIN(a, b) ((a) < (b) ? (a) : (b))#define MAX(a, b) ((a) == MIN((a), (b)) ? (b) : (a))typedef struct __node { int value; __node* next;} NODE, *PNODE;typedef const NODE* CPNODE;typedef struct __tnode { ... 阅读全文
posted @ 2011-09-05 14:55 lifengzhong 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 编程之美-3.5最短摘要 p229View Code 1 #include <iostream> 2 #include <cassert> 3 #include <cstring> 4 5 //编程之美-3.5最短摘要 6 bool minSumerize(const char (*wordArray)[20], int wordSize, const char (*queryArray)[20], int querySize, int& minStart, int& minEnd) 7 { 8 if (wordArray == NULL | 阅读全文
posted @ 2011-09-01 00:32 lifengzhong 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 求整型数组中最大子串方法总结:View Code 1 #include <iostream> 2 #include <cassert> 3 4 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 5 //判断两已排序数组是否有相同元素 6 bool sameNumber(const int* preArray, int preSize, const int* postArray, int postSize) 7 { 8 assert( preArray && postArray); 9 int preIndex = 阅读全文
posted @ 2011-08-30 16:12 lifengzhong 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目一: 线性时间内判断两有序数组是否有相同元素.题目二: 求数组最大子串(元素全负时返回0)View Code 1 #include <iostream> 2 #include <cassert> 3 //判断两已排序数组是否有相同元素 4 bool sameNumber(const int* preArray, int preSize, const int* postArray, int postSize) 5 { 6 assert( preArray && postArray); 7 int preIndex = 0; 8 int postInde 阅读全文
posted @ 2011-08-29 16:56 lifengzhong 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目: 链表环判断,不同链表是否有交点判断View Code 1 #include <iostream> 2 #include <cassert> 3 4 typedef struct __node { 5 int value; 6 __node* next; 7 } NODE, *PNODE; 8 9 bool circleJudge(const PNODE head)10 {11 assert(head);12 PNODE oneOffset = head, twoOffset = head->next;13 while (tru... 阅读全文
posted @ 2011-08-29 00:06 lifengzhong 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 题目:常用库函数实现。 1 #include <iostream> 2 #include <cassert> 3 void* myMemCpy(void* dest, const void* src, size_t length) 4 { 5 assert(dest && src); 6 char* charDest = static_cast<char*>(dest); 7 const char* charSrc = static_cast<const char*>(src); 8 bool special = charSrc 阅读全文
posted @ 2011-08-26 11:47 lifengzhong 阅读(208) 评论(0) 推荐(0) 编辑