本文介绍了从任何角度看,++ i和i + = 1有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是kn king的c编程提出的一个问题:一种现代方法.我不明白他给的解决方案:-
This is a question from kn king's c programming : a modern approach. I can't understand the solution given by him:-
The expression ++i is equivalent to (i += 1). The value of both expressions is i after the increment has been performed.无论如何我如何理解?
How do I understand this anyway?
推荐答案i = 10 printf("%d", i++);
将打印10,其中
printf("%d", ++i);将打印11
X = i++可以这样认为
X = i i = i + 1其中X = ++i是
i = i + 1 X = i所以
printf ("%d", ++i);与
printf ("%d", i += 1);但不是
printf ("%d", i++);尽管在这三个语句中的任何一个之后的i值都相同.
although value of i after any of these three statements will be the same.
更多推荐
从任何角度看,++ i和i + = 1有什么区别
发布评论