积极答复者
3维数组

问题
-
static employee emclassaemployee[40]
分成8组
static group kk[1]={emclassaemployee[1] ,emclassaemployee[2] ,emclassaemployee[3] ,emclassaemployee[4] ,emclassaemployee[5] ,,emclassaemployee[6] ,,emclassaemployee[7] ,,emclassaemployee[8]};
static group kk[2]={emclassaemployee[9] ............. ,,emclassaemployee[16]};
static group kk[2]=................
........................
不知道怎么表示
这算3维数组吗?
- 已编辑 Honny_yeyh 2012年2月19日 11:01
答案
-
Honny_yeyh你好!
在程序设计中,为了方便处理,把一些具有相同类型的若干变量按有序的形式组织起来,而形成的一种数据结构成为数组。构成数组的数据元素的类型也可以是数组,由一维数组构成的数组成为二维数组。由二维数组构成的数组就是三位数组。一维、二维数组的初始化形式如下所示,以此课类推出三位数组的初始化形式:
int one[5]={1,2,3,4,5}; int two[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};//3行4列 int three[3][4][5];//高为3,行为4,列为5.
40个int型数据,分成八组,每组5个,可以参考下面的代码:
static int one[40]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40}; int two[8][5];//8行5列的二维数组。 int count=0; for(int i=0;i<8;i++) { for(int j=0;j<5;j++) { two[i][j]=one[count]; count++; } }
希望我的回复对你有所帮助!
祝你好运!
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- 已建议为答案 Helen Zhao 2012年2月24日 8:05
- 已标记为答案 Helen Zhao 2012年2月27日 1:39
全部回复
-
可以这么写吗?
int aaa;
for (aaa=1;aaa<6;aaa++)
{
int bbb;
for (bbb=1;bbb<classteamcount;bbb++)
{
static group kk[aaa]={emclassaemployee[bbb] ,emclassaemployee[bbb++] ,emclassaemployee[bbb++] ,emclassaemployee[bbb++] ,emclassaemployee[bbb++] ,,emclassaemployee[bbb++] ,,emclassaemployee[bbb++] ,,emclassaemployee[bbb++]};
bbb++
}
}
-
Hi Honny_yeyh,
你能够访问下面的网站获得更多三位数组的信息:
http://www.dotnetperls.com/multidimensional-array
orichisonic http://blog.csdn.net/orichisonic If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
-
Honny_yeyh你好!
在程序设计中,为了方便处理,把一些具有相同类型的若干变量按有序的形式组织起来,而形成的一种数据结构成为数组。构成数组的数据元素的类型也可以是数组,由一维数组构成的数组成为二维数组。由二维数组构成的数组就是三位数组。一维、二维数组的初始化形式如下所示,以此课类推出三位数组的初始化形式:
int one[5]={1,2,3,4,5}; int two[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};//3行4列 int three[3][4][5];//高为3,行为4,列为5.
40个int型数据,分成八组,每组5个,可以参考下面的代码:
static int one[40]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40}; int two[8][5];//8行5列的二维数组。 int count=0; for(int i=0;i<8;i++) { for(int j=0;j<5;j++) { two[i][j]=one[count]; count++; } }
希望我的回复对你有所帮助!
祝你好运!
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- 已建议为答案 Helen Zhao 2012年2月24日 8:05
- 已标记为答案 Helen Zhao 2012年2月27日 1:39