“a”的价值是多少? int a = 3; int b = 5; a + =(a <b)? (1):( - 一) [英] What will be the value of “ a “? int a = 3; int b = 5; a += (a &lt; b)? (1):(-a)

查看:109
本文介绍了“a”的价值是多少? int a = 3; int b = 5; a + =(a <b)? (1):( - 一)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

a的价值是多少?





 int a = 3; 

int b = 5;

a + =(a< b)? (1):( - a)





我尝试过:



a的价值是多少?

解决方案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



我们当然不打算做你的通过查看它,或者通过编译和运行它作为代码,你可以在几秒钟内完成作业!



自己尝试一下,你可能会发现它不是你觉得很难!


我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技巧,它是旨在帮助您的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。

任何失败都会帮助你的老师发现你的弱点并设置补救措施。



你应该学会尽快使用调试器可能。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。 />


建议:有一个容易如何知道 a 的值,运行代码。


简答:使用调试器。



稍微长一点的回答:如果你假设 = <左边的 a ,这并不困难/ code>运算符是 的新值和右侧的所有(同一变量) a 的实例 = 是' '的当前值。

此外,

 a + = ... 



相当于

 a = a + ... 


What will be the value of " a "?


int a = 3;

int b = 5;

a += (a < b)? (1):(-a)



What I have tried:

What will be the value of " a "?

解决方案

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

And we certainly aren't going to do your homework when you could work it out in seconds by looking at it, or by compiling and running it as code!

Try it yourself, you may find it is not as difficult as you think!


We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.

Advice: there is an easy way to know the value of a, run the code.


Short answer: use the debugger.

Slightly longer answer: it is not difficult, if you assume that a on the left of the = operator is 'new value of a' and all the instances of (the same variable) a on the right of the = are 'current value of a'.
In addition,

a += ...


is equivalent to

a = a + ...


这篇关于“a”的价值是多少? int a = 3; int b = 5; a + =(a <b)? (1):( - 一)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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