分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

举例说明:

1)int* p[2] 是一个指向int型的指针数组,即:p是包含两个元素的指针数组,指针指向的是int型。

可以这样来用:

#include <iostream>using namespace std;int main(int argc, char* argv[]) {int* p[2];int a[3] = {1, 2, 3};int b[4] = {4, 5, 6, 7};p[0] = a;p[1] = b;for(int i = 0; i < 3; i++)cout << *p[0] + i;// cout << **p + i;cout << endl;for(i = 0; i < 4; i++)cout << *p[1] + i;// cout << **p + i;return 0;}

(2)对于 int (*p)[2], 它相当于一个二维数组的用法,只是它是一个n行2列的数组,可以这样来用:

#include <iostream>using namespace std;void main() {int (*p)[2];int b[3][2] = {{1, 2}, {3, 4}, {5, 6}};p = b;for(int i = 0; i < 3; i++) {for(int j = 0; j < 2; j++) //cout << p[i][j]; //cout << *(*(p+i)+j);cout << endl;}}

注意:

(1)为行数确定、列数不确定,即为2*n型的。

(2)为n*2型的数组的指针用法,即行数不确定、列数确定。

对于(1)其等价形式如下:

#include <iostream>using namespace std;void main() {int** array;array = new int* [2];int a[3] = {1, 2, 3};int b[4] = {4, 5, 6, 7};array[0] = a; // *array = a;array[1] = b; // *(array+1) = b;for(int i = 0; i < 3; i++) cout << array[0][i];// cout << *array[0] + i;cout << endl;for(int j = 0; j < 4; j++) cout << array[1][j];// cout << *array[1] + j;}


其实以上用法即这我们常用的动态二维数组的用法。

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

int p 与int p 的不同相关推荐

  1. linux longlong大小,Linux基本数据类型大小——int,char,long int,long long int

    转自: http://blog.163.com/zheng_he_xiang/blog/static/186505326201110272018548/ 在Linux操作系统下使用GCC进行编程,目前 ...

  2. const int * 、int * const、int const* 、const int a(){ } 和int a()const { }的区别和联系

    前言:很多人都把const int * .int * const.int const* 的区别和联系搞混,我自己在学习C++的过程中,也经常性          弄不 清楚,今天特意总结一下,作为学习 ...

  3. 喜闻乐见的const int *p、int* const p、const int* const p

    不废话直接代码示例: 1 void f(const int *p) { 2 3 int b = 10; 4 5 *p = 10; // error 6 7 p = &b; // fine 8 ...

  4. int(1) 和 int(10) 有什么区别?资深开发竟然分不清!

    欢迎关注方志朋的博客,回复"666"获面试宝典 困惑 最近遇到个问题,有个表的要加个user_id字段,user_id字段可能很大,于是我提mysql工单alter table x ...

  5. int(1) 和 int(10) 的区别?很多老程序都理解错了!

    欢迎关注方志朋的博客,回复"666"获面试宝典 最近开发遇到一个问题,涉及到了int(1) 和 int(10) 有什么区别?三年老开发也不知道,于是自己上网 google 研究了下 ...

  6. int(1) 和 int(10) 有什么区别?资深开发竟然都理解错了!

    文章来源:https://sourl.cn/ZVQP6t 困 惑 最近遇到个问题,有个表的要加个user_id字段,user_id字段可能很大,于是我提mysql工单alter table xxx A ...

  7. 2020-09-21C++学习笔记之与C语言区别和加强——四种const意义(const int a; int const b; const int *c; int * const d)

    2020-09-21C++学习笔记(const int a; int const b; const int *c; int * const d) 这两天在上课更新晚了. 1.C/C++中的const ...

  8. const int *,const int * const和int const *有什么区别?

    我总是搞砸了如何正确使用<code>const int* , const int * const和int const * . 是否有一组规则定义您可以做什么和不能做什么? 我想知道在分配, ...

  9. int*p[ ]与int(*p)[ ]的不同

    举例说明: 1)int* p[2] 是一个指向int型的指针数组,即:p是包含两个元素的指针数组,指针指向的是int型. 可以这样来用: #include <iostream> using ...

最新文章

  1. Android 中文 API 文档 (45) —— AbsoluteLayout.LayoutParams
  2. 盛大文学推出“一人一书”计划,发布电子书战略
  3. 快速创建 shell脚本
  4. Android OpenGL ES抗锯齿
  5. cv岗工作做什么_中字头施工单位的党建岗是做什么的?
  6. 吴晓然:实时通信需要Codec和网络模块结合
  7. 带你剖析WebGis的世界奥秘----Geojson数据加载(高级)
  8. 举例说明语言接触会造成哪些结果_语言学概论全真模拟演练(二)
  9. java 元素居中_如何在ColumnLayout中居中元素
  10. mac cad石材填充图案_CAD怎么填充颜色?
  11. 再谈矩阵分解在推荐系统中的应用
  12. 【算法】第76题 Minimum Window Substring
  13. 逆向破解之160个CrackMe —— 007
  14. 震惊!程序员一夜赚1W,没想到他就做了这个..........
  15. Google 浏览器(2011)书签同步
  16. UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0x80 in position 2
  17. Java中的BlockingQueue队列
  18. mysql文章相似度计算_文章相似度计算
  19. 架构师提升技术影响力的三个阶段(一)
  20. 手机订货系统的基本原理 帮助经销商卖货

热门文章

  1. DevExpress中透明玻璃效果
  2. 数据库访问类(使用存储过程的)
  3. Android Custom View系列《圆形菜单一》
  4. 13款经典JavaScript图形和图表绘制工具
  5. 理论实践都重要,交换机安装全接触
  6. Answer:关于C#连续赋值的面试题
  7. C++模板之特化与偏特化详解
  8. WPF数据绑定、多个元素
  9. Linux下tomcat安装及优化
  10. linux socket无延迟发送数据