问题描述
好的我正试图用t图解决这个问题
Ok I'm trying to figure out this problem using a t-chart
for (int i = 1; i < 5; i++)
for(int k = i; k > 2; k--)
System.out.print(k + "");
我的t-chart
My t-chart
i K
1 -
2 -
3 2
4 3
5 4
输出
2 3 4
假设是
3 4 3怎么样???
我尝试了什么:
问题在JGrasp中效果很好我只需要对输出进行更多说明
output
2 3 4
suppose to be
3 4 3 how???
What I have tried:
The problem works great in JGrasp I just need more clarification on the output
推荐答案
我的t-chart
你的图表错了,使用调试器,它会告诉你变量是如何逐步演变的。尝试一下,你会发现它很有启发性。
当你不明白你的代码在做什么或为什么它做它做的时候,答案就是答案是调试器。
使用调试器查看代码正在执行的操作。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量,这是一个令人难以置信的学习工具。
[]
[]
[]
调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。
调试器中没有魔法,它没有找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。
Your chart is wrong, use the debugger, it will show you how variables evolve step by step. Give it a try, you will see it is very instructive.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.
Debugger - Wikipedia, the free encyclopedia[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
这篇关于需要帮助澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!