标题:一道理论题,看不懂,求助!
只看楼主
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
结帖率:89.47%
已结贴  问题点数:20 回复次数:4 
一道理论题,看不懂,求助!
程序代码:
int main()

 {   
     double disgusting[3][4][5][6] = {{{{0}}}};  
     double (*ptr)[6] = _____;  
     ptr[2][3] = 2.3333;   
     return 0; } 

Which of the following expressions would be correct to fill in the blank?
A. disgusting[0]
 B. disgusting[2][1]
C. (double *[6])disgusting[4][3]
D. disgusting[0][3][2]

答案是B

2017-01-04 16:36
bjut_Allen
Rank: 9Rank: 9Rank: 9
来 自:平乐园工业技术学校
等 级:蜘蛛侠
威 望:8
帖 子:323
专家分:1223
注 册:2016-10-16
得分:5 
把disgusting[3][4]看成数组名是不是就选出来B了

Code is my life.
2017-01-04 18:26
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
得分:0 
回复 2楼 bjut_Allen
不知道,这是解析,没看懂
Explanation: disgusting[2][1] is of type double [5][6] , thus implicitly-convertible to type double (*)[6] . disgusting[0] is of type double [4][5][6] , convertible to type double (*)[5][6] .
double *[6] is a type for an array of six elements whose type is double * , and is different than double (*)[6] , a pointer to type double [6]
disgusting[0][3][2] is of type double [6] , convertible to type double * .
2017-01-04 18:40
bjut_Allen
Rank: 9Rank: 9Rank: 9
来 自:平乐园工业技术学校
等 级:蜘蛛侠
威 望:8
帖 子:323
专家分:1223
注 册:2016-10-16
得分:15 
double (*ptr)[6]声明了一个指向二维数组的指针,要传它一个二维数组的地址。所以是B啊。

Code is my life.
2017-01-04 18:47
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
得分:0 
回复 4楼 bjut_Allen
哦哦,理解了。谢谢啦!
2017-01-04 18:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-473287-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014776 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved