摘要: 阅读全文
posted @ 2014-07-21 16:48 galoishelley 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 指针数组的概念一维指针数组的定义形式为类型名*数组名[数组长度]; 例如int *p[4];可以用指针数组中各个元素分别指向若干个字符串,使字符串处理更加方便灵活 阅读全文
posted @ 2014-07-21 16:46 galoishelley 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 定义指针函数的一般形式为 类型名 *函数名(参数表列);例如int *a(int x,int y); 阅读全文
posted @ 2014-07-21 16:02 galoishelley 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 指针变量也可以指向一个函数。一个函数在编译时被分配给一个入口地址。这个函数入口地址就称为函数的指针。可以用一个指针变量指向函数,然后通过该指针变量调用此函数 1 #include 2 using namespace std; 3 4 int main() 5 { 6 int max(in... 阅读全文
posted @ 2014-07-21 15:26 galoishelley 阅读(710) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 int main() 5 { 6 void output(int (*p)[4]); 7 int a[3][4]={1,3,5,7,9,11,13,15,17,19,21,23}; 8 outp... 阅读全文
posted @ 2014-07-21 14:42 galoishelley 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 设有一个二维数组a,它有3行4列。它的定义为int a[3][4]={{1,3,5,7},{9,11,13,15},{17,18,21,23}};a是一个数组名。a数组包含3行,即3个元 素:a[0],a[1],a[2]。而每一元素又是一个一维数组, 它包含4个元素(即4个列元素),例如,a[0]所... 阅读全文
posted @ 2014-07-21 14:21 galoishelley 阅读(495) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 void select_sort(int *p, int n) 5 { 6 int i, j, k; 7 for(i = 0; i p[j])12 {13 ... 阅读全文
posted @ 2014-07-21 14:08 galoishelley 阅读(1766) 评论(0) 推荐(0) 编辑
摘要: 如果先使p指向数组a的首元素(即p=a),则:(1) p++(或p+=1)。使p指向下一元素,即a[1]。 如果用*p,得到下一个元素a[1]的值。(2) *p++。由于++和*同优先级,结合方向为自右而 左,因此它等价于*(p++)。作用是: 先得到p指向 的变量的值(即*p),然后再使p的值加1... 阅读全文
posted @ 2014-07-21 13:19 galoishelley 阅读(394) 评论(0) 推荐(0) 编辑