++ i和i ++之间的差异 [英] Diffrence between ++i and i++
问题描述
我在C语言课程中进行了期中考试。
我在100分中失去了18分,因为我并没有将这个杀戮事实归结为:
in(for循环)这两种方式在增加循环之间没有区别:
for(i = 0; i< 10; ++ i)
和
for(i = 0; i< 10; i ++)
(请注意i ++和++之间的差异)
您对此有何评论。
I made my midterm exam in the C language course.
I lost 18 marks off 100 because I didn''t relaize this killing fact:
in (for loops) there is no difference between incrementing the loop in
these two ways:
for (i=0; i < 10 ; ++i)
and
for (i=0; i < 10 ; i++)
( notice the difference is between i++ and ++i )
What are your comments on this.
推荐答案
lr******@yahoo.com (Luai)写道:
lr******@yahoo.com (Luai) writes:
in(for循环)这两种方式增加循环之间没有区别:
for(i = 0; i< 10; + + i)
和
for(i = 0; i< 10; i ++)
in (for loops) there is no difference between incrementing the loop in
these two ways:
for (i=0; i < 10 ; ++i)
and
for (i=0; i < 10 ; i++)
为什么你觉得它们可能有什么不同?
Why and how did you think they might be different?
On Sun,2004年4月11日20:26:04 +0000,Luai wrot e:
On Sun, 11 Apr 2004 20:26:04 +0000, Luai wrote:
我在C语言课程中进行了期中考试。
我在100分中失去了18分,因为我并没有将这个杀戮事实归结为:
in(for循环)这两种方式增加循环之间没有区别:
for(i = 0;我< 10; ++ i)
和
for(i = 0; i< 10; i ++)
(注意区别在于i ++和++ i)
您对此有何评论。
I made my midterm exam in the C language course.
I lost 18 marks off 100 because I didn''t relaize this killing fact:
in (for loops) there is no difference between incrementing the loop in
these two ways:
for (i=0; i < 10 ; ++i)
and
for (i=0; i < 10 ; i++)
( notice the difference is between i++ and ++i )
What are your comments on this.
听起来不错。通常,++ i和i ++的含义是你在c中学到的第一个
的东西之一。所以,如果你一直到期中没有
学习这个,这不是一个好兆头。现在你知道如果你想要一个好的成绩(分数),你需要在决赛前学习一下
。
HTH
--Mac
Sounds about right. Usually the meaning of ++i and i++ is one of the first
things you learn in c. So, if you got all the way to the midterm without
learning this, it is not a good sign. Now you know you need to study a
little more before the final if you want a good grade (mark).
HTH
--Mac
lr * *****@yahoo.com (Luai)写道:
我在C语言课程中进行了期中考试。
因为我没有减掉18分不要重新理解这个杀戮事实:
in(for循环)这两种方式增加循环之间没有区别:
for(i = 0; i< 10; ++ i)
相当于:
i = 0;
while(i< 10)
{
++ i;
}
和
for(i = 0; i< 10; i ++)
相当于:
i = 0;
while(i< 10)
{
i ++;
}
您对此有何评论。
I made my midterm exam in the C language course.
I lost 18 marks off 100 because I didn''t relaize this killing fact:
in (for loops) there is no difference between incrementing the loop in
these two ways:
for (i=0; i < 10 ; ++i)
which is equivalent to:
i = 0;
while ( i < 10 )
{
++i;
}
and
for (i=0; i < 10 ; i++)
which is equivalent to:
i = 0;
while ( i < 10 )
{
i++;
}
What are your comments on this.
因为在这两种情况下都是
的副作用(增量i),其值被丢弃,
实际上没有差别。
HTH
问候
-
Irrwahn Grausewitz(ir*******@freenet.de)
欢迎来到clc: http:// www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list: http://www.faqs.org/faqs/C-faq/faq/
clc OT指南:< a rel =nofollowhref =http://benpfaff.org/writings/clc/off-topic.htmltarget =_ blank> http://benpfaff.org/writings/clc/off-topic.html
Since in both cases the iteration statement is evaluated only
for its side effect (increment i), while its value is discarded,
there''s effectively no difference.
HTH
Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
这篇关于++ i和i ++之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!