如何在C + plus中创建2D数组 [英] How to create 2D array in C plus plus

查看:83
本文介绍了如何在C + plus中创建2D数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



A)创建大小为2的数组[4] [3]然后从键盘向数组的第1列插入值并指定0所有其他元素。



B)编写一个名为dispalyArray()的函数来显示内容。



void dispalyArray(int arr [] [4],int rows,int columns);



请帮助我..



我尝试了什么:



我对数组知之甚少。所以试着从头开始学习数组。

解决方案

因为它看起来像你的作业,我给你链接关于数组的教程



还有一些额外的提示:

< pre lang =c ++> int arr [ 4 ] [ 3 ] = { 0 }; // 初始化一个大小为4 x 3且值为0的二维数组
arr [ 1 ] [ 0 ] = 3 ; // 在位置设置值
int value = arr [ 1 ] [ 0 ]; // 获取值





输出为在屏幕上,您可以使用打印命令。



有了这些知识,它真的应该很容易。


我们不做你的家庭作业。

HomeWork不会测试你乞求别人的技能为了完成你的工作,它将帮助你的老师检查你对所学课程的理解,以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,开始工作吧。如果您遇到特定问题,请显示您的代码并解释这个确切的问题,我们可以提供帮助。



这里是C和C ++参考书的链接这些语言的作者。注意,C是C ++的祖先,所以知道C对C ++总是有用。

C编程语言 - 维基百科,免费的百科全书 [ ^ ]

https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2。 pdf [ ^ ]

http://www.ime.usp。 br / ~pf / Kernighan-Ritchie / C-Programming-Ebook.pdf [ ^ ]



C ++编程语言 [ ^ ]


如果你真的对 C ++ 数组感兴趣,那么还要看看 std :: array [ ^ ] class。


Hi,
A) Create 2D array of size[4][3] Then insert values to the 1st column of the array from the keyboard and assign 0 for all the other elements.

B) Write a function called dispalyArray() to display the content.

void dispalyArray (int arr[][4], int rows, int columns);

Please help me..

What I have tried:

I do not know much about arrays. So trying to learn about arrays from the beginning.

解决方案

Because it looks like your homework I give you the link to tutorial about arrays.

And some additonal tips:

int arr[4][3] = {0};//init a 2-dimensional array with size of 4 x 3 with value of 0
arr[1][0] = 3;//setting a value at position
int value = arr[1][0];//getting the value 



For output on the screen you can use the print command.

With that knowledge it really should be very easy.


We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, start working. If you are stuck on a specific problem, show your code and explain this exact problem, we may help.

Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

C++ Programing Language[^]


If you are really interested in C++ arrays, then have also a look at std::array[^] class.


这篇关于如何在C + plus中创建2D数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆