摘要: 一.指针使用指针访问数据*pValue需二次访存,第一次访存,得到存放该数据的地址pValue,第二次访存,得到该内存地址存放的数据*pValue1.指针的声明和赋值 声明 dataType *pValue; 以整形为例 int count=5; int *pValue=&count; 或 int *pValue; int count=5; pValue=&count; pValue的值是count的内存地址, *pValue=52.数组与指针 dataType Array[n]; //数组变量Array表示的是该数组的起始地址 dataType... 阅读全文
posted @ 2013-04-09 17:28 MinZhang 阅读(658) 评论(0) 推荐(0) 编辑
摘要: 第一部分:准备Ubuntu12.04的启动盘Ubuntu支持可移动盘和CDROM安装,笔者选择后者。在Ubuntu官网http://www.ubuntu.org.cn/download/desktop下载Ubuntu镜像文件(.iso),通过光盘刻录机将该镜像文件刻录到一张空白CD/DVD上。第二部分:安装Ubuntu12.04第一步、将CD/DVD启动盘插入光驱中,一般长按键盘左上角的Esc键,进入启动页面,选择CDROM安装。第二步、分区 安装时有三个选项,选择最后一个手动分区。自动分区Ubuntu会覆盖整个硬盘,手动分区可以选择安装大小,若计算机还要装其他系统,则选择手动分区... 阅读全文
posted @ 2013-03-18 10:05 MinZhang 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序算法是一种比较简单的排序算法,它的核心思想是:重复地比较相邻的两个元素,若不满足排序规则,则交换。假设从小到大排列数组A,其中A有n个元素。排序进行n趟,每一趟都将最小的元素交换到前面。程序实现如下:int bubblesort(int A[LEN],int n){ int i,j,temp=0; for(i=0;i<n;i++) //进行n趟排序 for(j=n-1;j>i;j--) //从最上面开始 if(A[j]<A[j-1]) //将小的元素交换到下面 { temp=A[j]; A[j]=A[j-1]; ... 阅读全文
posted @ 2013-03-05 18:58 MinZhang 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;const int LEN=100;int insertion_sort(int A[LEN],int n){ int key,i; for(int j=1;j<n;j++) { key=A[j]; i=j-1; while(i>=0&&A[i]>key) { A[i+1]=A[i]; i=i-1; } A[i+1]=key; } return 0;}int main(){ int n; cout<<"input the leng... 阅读全文
posted @ 2013-03-03 11:33 MinZhang 阅读(216) 评论(5) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;const int MAX=100000;const int LEN=100;//按从小到大的排列合并数组A,其中A的p~q和q+1~r部分是已经排好序的 int merge(int A[LEN],int p,int q,int r)//p,q,r是数组下标 { int n1=q-p+1; int n2=r-q; int L[LEN],R[LEN];//设置一个左右数组 for(int i=0;i<n1;i++)//将A的p~q部分赋给左数组 L[i]=A[p+i]; for(i=0;i<n2; 阅读全文
posted @ 2013-03-02 19:51 MinZhang 阅读(365) 评论(0) 推荐(0) 编辑