搜索
编程论坛
→
开发语言
→
『 C语言论坛 』
→ 问问数组和数组元素的区别?
标题:
问问数组和数组元素的区别?
只看楼主
游戏而已
等 级:
新手上路
帖 子:15
专家分:0
注 册:2005-3-19
楼主
问题点数:0 回复次数:9
问问数组和数组元素的区别?
int a[10]; /* 这是数组 * /
a[10] /* 这是数组元素 */
int a[i]; /* 这是错误的 */
a[i] /* 这是正确的 */
是这样么??
[此贴子已经被作者于2005-8-23 18:42:35编辑过]
搜索更多相关主题的帖子:
元素
2005-08-23 18:42
caiyakang
等 级:
新手上路
威 望:
5
帖 子:2111
专家分:0
注 册:2005-3-24
第
2
楼
得分:0
int a[i];
定义数组的类型
总起来说就是,数组要先定义后使用。
中国人的财富网:http://www..cn/
2005-08-23 19:17
游戏而已
等 级:
新手上路
帖 子:15
专家分:0
注 册:2005-3-19
第
3
楼
得分:0
int a[i]; /* 这个是对的????*/
/in.asp?id=ncliang" target="_blank">
/p/2005/0723/2389/b_15B366214465147B.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://photo./p/2005/0723/2389/b_15B366214465147B.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
/msgrd?V=1&Uin=5941998" target="_blank">
/12_offline.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://wpslogo./12_offline.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-08-23 19:33
caiyakang
等 级:
新手上路
威 望:
5
帖 子:2111
专家分:0
注 册:2005-3-24
第
4
楼
得分:0
原理上是不对啊,我是举个例子啊
int a[i];
i不能为变量,只能为常量。
改成这样
#define I 10
int a[i];
这样就对了,
或者int a[10];
中国人的财富网:http://www..cn/
2005-08-23 19:38
zhangxih4
等 级:
新手上路
帖 子:15
专家分:0
注 册:2005-8-17
第
5
楼
得分:0
错的,i是什么。没定义过
2005-08-23 19:39
游戏而已
等 级:
新手上路
帖 子:15
专家分:0
注 册:2005-3-19
第
6
楼
得分:0
我明白了
谢谢啊。。。
/in.asp?id=ncliang" target="_blank">
/p/2005/0723/2389/b_15B366214465147B.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://photo./p/2005/0723/2389/b_15B366214465147B.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
/msgrd?V=1&Uin=5941998" target="_blank">
/12_offline.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://wpslogo./12_offline.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-08-23 19:43
水影月圆
等 级:
贵宾
威 望:
11
帖 子:738
专家分:0
注 册:2005-8-2
第
7
楼
得分:0
已经定义拉!!~
#define I 10 /* 这里 i 已经定义了,是个宏*/
子非鱼,安知鱼之江湖?子非我,安知我之功夫 http://20681.
2005-08-23 19:44
wenyong
等 级:
新手上路
帖 子:251
专家分:0
注 册:2005-8-9
第
8
楼
得分:0
int a[10] /* 定义一个数组,*/
a[10] /*数组里面的第11个元素*/
2005-08-24 09:02
zhangxih4
等 级:
新手上路
帖 子:15
专家分:0
注 册:2005-8-17
第
9
楼
得分:0
我发的时候你的帖子还没显示出来,所以我是说楼主的程序。.....
2005-08-25 20:36
袋鼠
等 级:
新手上路
帖 子:40
专家分:0
注 册:2005-7-19
第
10
楼
得分:0
对于4楼的,
#define I10
int a[I]
这样才是对的嘛,要区分大小写的
对于搂主的,
int a[10] /* 定义一个数组,长度为10 */
a[10] /* 使用数组元素,但这是错误的 */
/* 定义数组长度为10,因为数组下标是从0开始,所以数组元素从 a[0]到 a[9],a[10]是不存在的*/
int a[i] /* 定义一个数组,长度为i ,但这种定义方式是错误的,因为是i变量,而在C语言中是不支持定义动态数组的*/
a[i] /* 正确,使用数组元素a[i],但注意此处的i 不同于上一行里的i,应小于上面的i, 以防止出现第一个问题*/
爱编程,爱生活
2005-08-26 18:14
10
1/1页
1
参与讨论请移步原网站贴子:
https://bbs.bccn.net/thread-25870-1-1.html
关于我们
|
广告合作
|
编程中国
|
清除Cookies
|
TOP
|
手机版
编程中国
版权所有,并保留所有权利。
Powered by
Discuz
, Processed in 1.065082 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved