| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2537 人关注过本帖
标题:我预期的结果是30 ,为什么程序运行的结果是25?
只看楼主 加入收藏
luoshihao
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-9-1
收藏
得分:0 
undefined
2009-09-06 14:35
redice
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:902
专家分:0
注 册:2006-12-11
收藏
得分:0 
回复 27楼 prankmoon
还是 汇编有说服力 ,呵呵。

鲲鹏数据 - 专业Web数据采集服务提供者
http://www.
2009-09-06 19:34
redice
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:902
专家分:0
注 册:2006-12-11
收藏
得分:0 
回复 19楼 xiongli181
这个问题提的好,继续关注

鲲鹏数据 - 专业Web数据采集服务提供者
http://www.
2009-09-06 19:36
redice
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:902
专家分:0
注 册:2006-12-11
收藏
得分:0 
回复 36楼 yuehai1117
有一定说服力  

鲲鹏数据 - 专业Web数据采集服务提供者
http://www.
2009-09-06 19:38
Kabie
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:69
专家分:185
注 册:2009-8-21
收藏
得分:0 
a[i] = i++;
The question is whether the subscript is the old value of i or the new. Compilers can interpret
this in different ways, and generate different answers depending on their interpretation. The
standard intentionally leaves most such matters unspecified. When side effects (assignment to
variables) take place within an expression is left to the discretion of the compiler, since the best
order depends strongly on machine architecture.


C programing 明确说了。。。在这种情况下使用哪个值根本不是C语言定的。。。全看编译器想怎么解释……

所以永远不要在一个表达式内多次使用被该表达式改变的变量。。。
2009-09-12 10:55
在路上1225
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-9-9
收藏
得分:0 
我的理解和六楼一样     ,可输出是25...可能哪点没理解透?
谁再指点一下,详细点.......谢了...
2009-09-12 12:08
帅超
Rank: 2
等 级:论坛游民
帖 子:25
专家分:23
注 册:2009-9-12
收藏
得分:0 
b=++a*--a

++a过后,a就变成6了,
所以--a就是6自减,变成5.
b=5*6=30.。这样
2009-09-12 12:18
快速回复:我预期的结果是30 ,为什么程序运行的结果是25?
数据加载中...
 
   



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

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