二维数组 [英] two dimensional array

查看:124
本文介绍了二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用指针声明二维数组。但它没有工作,任何想法?

解决方案

* Someonekicked:

im试图使用指针声明二维数组。但它没有工作,有什么想法吗?




使用std :: vector。


具体例子,参见
$ 1.7 $ b< url:http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01.html>的第1.7章。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?


" Someonekicked"写道:

我试图用指针声明一个二维数组。但它没有工作,有什么想法?




喜欢这样:


#include< iostream>

使用命名空间std;


// ------------------

void test2(int b [] [5])

{

cout<< b [2] [3]<< endl;

}

// ====================

int main()

{

int(* a)[5] = new int [3] [5];

a [2] [ 3] = 2048;

test2(a);

cin.get();

}




" Someonekicked" <所以*********** @ comcast.net>在消息新闻中写道:VS ******************** @ comcast.com ...

|我试图使用指针声明一个二维数组。但它不是

|工作,有什么想法吗?

|


编程首先进行通信。

1)矩阵是否知道行和编辑时或运行时的列?

2)为什么不工作?代码在哪里?

3)你是如何表达矩阵的?作为行* col大小的单个数组,还是作为保存数组的数组?

请参阅C ++ faq lite(google it)获取第一个提示。

im trying to declare a two dimensional array using pointers. but it is not
working, any ideas?

解决方案

* Someonekicked:

im trying to declare a two dimensional array using pointers. but it is not
working, any ideas?



Use std::vector.

For concrete examples, see chapter 1.7 of
<url: http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01.html>.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


"Someonekicked" writes:

im trying to declare a two dimensional array using pointers. but it is not
working, any ideas?



Like this:

#include <iostream>
using namespace std;

//------------------
void test2(int b[][5])
{
cout << b[2][3] << endl;
}
//====================
int main()
{
int(*a)[5] = new int[3][5];
a[2][3] = 2048;
test2(a);
cin.get();
}



"Someonekicked" <so***********@comcast.net> wrote in message news:Vs********************@comcast.com...
| im trying to declare a two dimensional array using pointers. but it is not
| working, any ideas?
|

Programming is communicating in the first place.
1) Does the matrix know the rows and columns at compile time or run time only?
2) Why isn''t working? Where is the code?
3) How did you express the Matrix? As a single array of row*col size, or as an array holding arrays?

See the C++ faq lite (google it) for your first hints.


这篇关于二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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