C++ 数组作为参数的传递
//#include <iostream>
//#include <conio.h>
//using namespace std;
//
//
//void are7(int(&arr)[3][4]); //引用的方式
//void are6(int(*arr)[3][4]); //二维数组指针的方式
//void are5(int *arr, int, int); //一维指针方式
//void are4(int **arr, int, int); //动态分配
//void are3(int(*arr)[4], int); //传入高
//void are2(int arr[][4], int); //传入高
//void are1(int arr[][4]); //高不用填,但一定要一个列
//
//int main()
//{
// //int arr2[3][4] = {
// // { 1, 2, 3 },
// // { 4, 5, 6, 7 },
// // { 8, 9, 10, 11 },
// //};
// //are1(arr2);//二维数组直接传递,退化为指针
// //are2(arr2, 3);
// //are3(arr2,3);
// //int *p = &arr2[0][0];
// //are4(&p, 3, 4);
// //are5((int*)arr2,3,4);
// //are5(arr2[0],3,4);
// //are6(&arr2);
// //are7(arr2);
// system("pause");
// return 0;
//}
//void are1(int arr[][4])
//{
// for (int i = 0; i < 3; i++)
// {
// for (int j = 0; j < 4; j++)
// {
// cout << arr[i][j] << " ";
// }
// cout << endl;
// }
//}
//void are2(int arr[][4], int len)
//{
// for (int i = 0; i < len; i++)
// {
// for (int j = 0; j < 4; j++)
// {
// cout << arr[i][j] << " ";
// }
// cout << endl;
// }
//}
//void are3(int(*arr)[4], int len)
//{
// for (int i = 0; i < len; i++)
// {
// for (int j = 0; j < 4; j++)
// {
// std::cout << arr[i][j] << " ";
// }
// std::cout << std::endl;
// }
//}
//void are4(int **arr, int len, int row)
//{
// arr = new int*[len];
// for (int i = 0; i < len; i++)
// {
// arr[i] = new int[row];
// }
// for (int i = 0; i < len; i++)
// {
// for (int j = 0; j < row; j++)
// {
// std::cout << arr[i][j] << " ";
// }
// std::cout << std::endl;
// }
//}
//void are5(int *arr, int len, int row)
//{
// for (int i = 0; i < len; i++)
// {
// for (int j = 0; j < row; j++)
// {
// std::cout << arr[j + i * row] << " ";
// }
// std::cout << std::endl;
// }
//}
//void are6(int(*arr)[3][4])
//{
// for (int i = 0; i < 3; i++)
// {
// for (int j = 0; j < 4; j++)
// {
// std::cout << (*arr)[i][j] << " ";
// }
// std::cout << std::endl;
// }
//}
//void are7(int(&arr)[3][4])
//{
// for (int i = 0; i < 3; i++)
// {
// for (int j = 0; j < 4; j++)
// {
// std::cout << arr[i][j] << " ";
// }
// std::cout << std::endl;
// }
//}
C++ 数组作为参数的传递的更多相关文章
- ref引用类型,数组型参数,out输出参数
ref和out的相同点和不同点 共同点:都是引用传递不同点:ref的参数在调用之前一定要赋值,在方法调用的过程中可以不要赋值. out的参数在调用之前可以不赋值,在方法调用的过程中一定要赋值. ...
- 你好,C++(26)如何与函数内部进行数据交换?5.1.3 函数参数的传递
5.1.3 函数参数的传递 我们知道,函数是用来完成某个功能的相对独立的一段代码.函数在完成这个功能的时候,往往需要外部数据的支持,这时就需要在调用这个函数时向它传递所需要的数据它才能完成这个功能获 ...
- (转)Java程序利用main函数中args参数实现参数的传递
Java程序利用main函数中args参数实现参数的传递 1.运行Java程序的同时,可以通过输入参数给main函数中的接收参数数组args[],供程序内部使用!即当你在Java命令行后面带上参数,J ...
- [转]数组引用:C++ 数组做参数 深入分析
"数组引用"以避免"数组降阶"(本文曾贴于VCKBASE\C++论坛) 受[hpho]的一段模板函数的启发,特写此文,如有雷同,实在遗憾. 数组降阶是个讨厌的事 ...
- 工作中的趣事:聊聊ref/out和方法参数的传递机制
0x00 前言 我在之前的游戏公司工作的时候,常常是作为一只埋头实现业务逻辑的码农.在工作之中不常有同事会对关于编程的话题进行交流,而工作之余也没有专门的时间进行技术分享.所以对我而言上家虽然是一家游 ...
- C++数组做参数
首先,看一下下面这段代码: void changearr(int a[],int n){ cout<<sizeof(a)<<endl; // 输出4}in ...
- mybatis中String参数的传递
mybatis中String参数的传递 Keywords selectKeywords(@Param("key") String key); 可以在mapper方法的参数钱添加 @ ...
- Java 一维数组作为参数和返回值
一维数组作为参数: 传数组的引用 创建数组直接传,本质也是传数组的引用 传null public class Test { //数组作为参数时,可以传递3中形式 public void m1(int[ ...
- C#编程(三十四)----------数组作为参数
原文链接: http://blog.csdn.net/shanyongxu/article/details/46765267 数组作为参数 数组可以作为参数传递给方法,也可以从方法中返回.要返回一个数 ...
随机推荐
- git安装和使用方法url
1.如何在ubuntu下使用Github? https://blog.csdn.net/tina_ttl/article/details/51326684 https://segmentfault.c ...
- 【转载】网易极客战记官方攻略-地牢-严酷考验 B
关卡连接:https://codecombat.163.com/play/level/the-gauntlet-b 免费试玩:https://codecombat.163.com/play 使用你的所 ...
- vue生命周期-标注
作者:FlyDragon 出处:http://www.cnblogs.com/fly_dragon/ 关于作者:专注于微软平台项目架构.管理和企业解决方案.如有问题或建议,请多多赐教! 本文版权归作者 ...
- CSP 初赛复习 密码
CSP 初赛复习 密码是\(xj\)机房学生端密码
- SpringBoot - @ControllerAdvice 处理异常
在Spring 3.2中,新增了@ControllerAdvice.@RestControllerAdvice 注解,可以用于定义@ExceptionHandler.@InitBinder.@Mode ...
- pygame游戏框架
#_author:来童星#date:2019/12/22 import pygame import sys pygame.init() size=width,height=640,480 screen ...
- 深入理解MAGENTO – 第九章 – 数据集合瓦瑞恩
本来,作为一个PHP程序员,如果你想攒一组变量的相关你有一个选择,古老的 阵列 . 尽管共享一个地址的名称与C存储器的阵列,一个PHP数组是一种通用的字典可变数组索引像数值对象结合行为的影响. 在其他 ...
- 学习Caffe(一)安装Caffe
Caffe是一个深度学习框架,本文讲阐述如何在linux下安装GPU加速的caffe. 系统配置是: OS: Ubuntu14.04 CPU: i5-4690 GPU: GTX960 RAM: 8G ...
- (52) C# 串口通讯
一.串口通讯基本参数 1.波特率:每秒传输n个多少个二进制位. 例如 9600 b/s = 1200 B/s= 1.172KB/S 2.传输数据格式 数据格式由起始位(start bit).数据位 ...
- ajax - getJSON() 方法
$("body").on("click",".layui-input-inline:eq(3)",function(){ $(this).f ...