- 博客(23)
- 资源 (1)
- 收藏
- 关注
原创 计算机网络中的小端大端
以下摘自stanford的intro to network 1-8 notes.least significant bit:最低位most significant bit:最大位different processors have different endianness. for example: x86 is little endian, arm is big endian.测试
2014-03-07 16:28:11
771
转载 同余 congruence of squares
转自:http://blog.youkuaiyun.com/leonharetd/article/details/12918659数学上,两个整数除以同一个整数,若得相同余数,则二整数同余(英文:Modular arithmetic;德文:Kongruenz)。同余理论常被用于数论中。最先引用同余的概念与符号者为德国数学家高斯。同余同余理论是初等数论的重要组成部分,
2014-02-22 10:33:08
869
原创 算法导论第三版4.1习题解答
4.1-2use brute-force to solve the maximum_subarray problem.#include #include #include #includeusing namespace std;void max_subarray(int A[], int low, int high){ int profit = INT_MIN; in
2014-02-12 14:49:17
1950
原创 算法导论第三版4.1最大和子数组思考
对于maximum_subarray的分治算法:#include #include #include #include using namespace std;int max_crossing_subarray(int A[], int low, int mid, int high, int& sub_low, int& sub_high){ int sum = 0; int
2014-02-10 15:38:53
846
原创 2.3-系列习题总结
(待补全)#include #include #include using namespace std;void merge(int A[], int p, int q, int r)//归并排序{ int i,j,k; int n1,n2; n1 = q - p + 1; n2 = r - q; int *L = new int[n1]; int *R = new
2014-01-08 22:52:11
695
原创 2.2-2习题总结(选择排序)
(待补全)#include #include #include using namespace std;void select_sort(int A[], int length){ int i,j,key,flag; for(i = 0; i < length - 1; i++) { key = A[i]; flag = i; for(j = i + 1; j
2014-01-08 22:21:22
738
转载 栈和堆 全局变量 静态变量存放的位置
memory:stack vs heap原文地址:http://gribblelab.org/CBootcamp/7_Memory_Stack_vs_Heap.html(待补)
2014-01-08 20:04:02
774
原创 2.1-4习题总结
习题是这个样子的:Consider the problem of adding two n-bit binary integers, stored in two n-element arrays A and B.The sum of the two integers should be stored in binary form in an (n+1)-element array C.Sta
2014-01-08 19:59:40
795
转载 详细讲解海明码的文章
详细讲解海明码的文章http://blog.youkuaiyun.com/TMS_LI/article/details/6258788
2013-11-05 13:45:39
631
原创 生成11位号码
//说明:手机号为11位,第一位为固定的1,第二位在3,5,8三个数中取,剩余为随机数#include #include#includeusing namespace std;//生成0-9的随机数int rand_ten(){return rand()%10;}//返回10的n次方double power_n(int n){
2013-10-28 22:42:44
1108
原创 函数形参
非引用形参和引用形参 指针形参 指针引用形参 总结:非引用形参(1)普通的非引用类型的参数通过复制对应的实参实现初始化。当用实参副本初始化形参时,函数并没有访问调用所传递的实参本身,因此不会修改实参的值。(2)指针形参(也属于普通的非引用形参)函数的形参可以是指针,此时将复制实参指针。与其他非引用类型的形参一样,
2013-10-10 18:27:05
1140
转载 类中的静态成员变量 非静态成员变量的初始化问题
#include using namespace std;struct a{ int m;};struct b : public a{ int n =8;};int n =8这行报错,因为类的非静态成员不能在类中初始化。1. 为什么类的静态成员变量不能在类中初始化 在C++中,类的静态成员(static member)必须在类内声明,在类外
2013-10-09 19:31:54
2140
1
原创 stl_list的back()函数疑问与解析
stl_list.h的back( )函数是这样的:reference back( ){return *(--end());}iterator end(){return node;}其中reference定义为:typedef T value_type;typedef value_type& reference;一开始我的疑问是:
2013-09-24 08:19:10
1763
原创 仿list的iterator
#includeusing namespace std;struct _iterator{int a;_iterator(int m):a(m){}};_iterator add(int a, int b){return a+b;}void main(){add(4, 2);}
2013-09-23 19:54:39
738
原创 list中节点如何与迭代器关联(List中iterator begin() { return (link_type)((*node).next); }的疑问)
今天在看list的时候遇到了下面同样的问题:在stl的List中 begin 是这样的iterator begin() { return (link_type)((*node).next); }我想知道 编译器自动对于 like_type 进行转化了吗。 iterator 是一个类,link_type只是类里面一个成员变量,怎么直接就能把返回值的link_type 转化为 iterat
2013-09-23 19:52:04
997
原创 模板类的静态成员变量
我自己写了一个简易的空间适配器代码如下,后来发现,不同类型的类模板共享的静态成员变量不是同一块。这可以通过查看不同类型类模板静态成员的地址,地址相同,表示共享的是同一块,不同则表示不是同一块。cout::free_list[i]cout::free_list[i]也就是说:类模板的静态成员变量是所有同类型的类模板实例共享的一块数据。#include#includeu
2013-09-16 14:16:50
2100
原创 强制转换
为了体验一下强制转换,我写了如下几行程序#include using namespace std; void main(){char * a = (char *) malloc(100);int * p =(int *)a;int *q= p;*p=1;p++;*p=2;for(int i=1;i{cout ++q;
2013-09-13 16:46:51
658
原创 如何锻炼写代码能力
最近一直在看侯捷的《STL源码剖析》,看到第二张的空间配置器的时候,对于次级空间配置器中的obj这个结构体以及对它的运用不是很清楚,然后自己就写了一个简化的obj以及测试代码。在写这些代码之前,我抄写了alloc.h中的大部分代码和vector.h中的部分代码,实现了一个简化了的vector。在这过程中,我感觉自己几乎理解了大部分源码。可是接下来,在写一个简化了的obj以及测试代码的过程中
2013-09-13 16:41:37
3861
原创 对空指针赋值的问题 指针的指针 指针的指针和指针数组
关于对空指针赋值的问题首先说一下什么是指针:假设 有语句 int a=10;那么编译器就在内存中开辟1个整型单元存放变量a,我们假设这个整型单元在内存中的地址是 0x1000;那么内存0x1000单元中存放了数据10,每次我们访问a的时候,实际上都是访问的0x1000单元中的10.现在定义:int *p; p=&a;当编译器遇到语句int *p
2013-09-11 17:14:32
3400
原创 如何启动bochs
bochs启动的时候需要配置文件,默认的是.bochsrc,这个文件就在你安装bochs的文件夹下面。我的是在usr/bochs/bochs-2.5.1下面。为什么需要配置文件呢?因为你需要告诉bochs,你希望的虚拟机是什么样子的。比如,内存多大,磁盘映像等。现在我在/usr/test下编写了boot.asm,并且生成boot.bin文件。然后使用bximage命令,生成一个软盘,打算让
2013-09-06 15:34:19
3290
原创 使用bochs的组件bximage 报错:could not write disk image
我在ubntu的/usr下新建了目录test,然后到test下使用bximage新建一个软盘映像,Do you want to create a floppy disk image or a hard disk image?Please type hd or fd. [hd] fdChoose the size of floppy disk image to create, in
2013-09-06 13:14:00
1759
原创 学习《orange's 一个操作系统的实现》准备
1.下载一个虚拟机 vbox2.下载一个ubuntu的iso文件(700多M)3.在vbox上安装ubuntu操作系统4。ubuntu操作系统中必须要安装以下几个软件:gccgnu makenasmsamba其中,gcc:是c++的编译器 gnu make:在linux环境下使用gnu make 能够构建一个属于自己的工程,整个工程的编译只需
2013-09-04 11:17:01
796
原创 smba软件
smba软件是linux系统上实现SMB协议的一个免费软件。SMB是一种在局域网上共享文件,打印机的一种通信协议。SMB协议来源历史溯源在早期网络世界当中,档案数据在不同主机之间的传输大多是使用 FTP 这个好用的服务器软件来进行传送。不过,使用FTP 传输档案却有个小小的问题,那就您无法直接修改主机上面的档案数据!也就是说您想要更改Linux 主机上的某个档案时,必需要由
2013-09-04 10:58:43
932
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人