基于C的问题(为什么k变为零)........................................ ................. [英] C based question( Why k comes to zero).........................................................

查看:65
本文介绍了基于C的问题(为什么k变为零)........................................ .................的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main()
{

int i=-3,j=2,k=0,m;
m=++i&& ++j||++k;
printf("%d%d%d%d",i,j,k,m);
return 0;

}



我的答案是



i = -2

j = 3

k = 1

m = 1



实际答案

i = -2

j = 3

k = 0

m = 1



问这个k如何变为0(零)


My answer is

i=-2
j=3
k=1
m=1

Actual answer
i=-2
j=3
k=0
m=1

Question how this k comes to 0(zero)

推荐答案

这不是C#而不能编译成C#。如果你需要帮助,你不应该这么不准确。



-SA
This is not C# and cannot compile as C#. You should not be so inaccurate if you want help.

—SA


参考这个链接



功能如何运作 [ ^ ]




您的答案在您的问题中.. :-)



使用运算符..

使用逻辑运算符第一&&运算符由于先前的高优先级而工作,所以i和j以1递增并由于||运算符它只适用于j而不是k ..你可以交换j和k然后你可以得到j不是增量但是k会递增。



由于||运算符任何一个条件都是真的,它有效...



m = ++ i && ++ j || ++ k;





: - )
Hi,
Your answer is in your question..:-)

The use of operators..
use of logical operator the first && operators is works due to preceding high priority so i and j increment with 1 and due to || operator it works only for j not for k .. you can swap j and k then you can get j is not increment but k will increment.

Due to || operator any one condition is true, It works...

m=++i&& ++j||++k;


:-)


这篇关于基于C的问题(为什么k变为零)........................................ .................的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆