我看到这个公式几乎每个代码都会生成一个pascal三角形

我看到这个公式几乎每个代码都会生成一个pascal三角形

问题描述:

您好,

我正在查看生成pascal三角形的代码,每隔一段时间我就会看到这个公式:

a =(a *(x - y) )/(y + 1));



包含在他们的代码中,我不太明白为什么它存在,因为它会产生每个值0时间。



这个公式对生成三角形有什么作用?



我是什么尝试过:



是的,我已经在我的代码上尝试了它并且它完美无缺。

Hello,
I was looking through codes that generate a pascal triangle and every once in awhile I will see this formula :
a = (a* (x - y)/ (y + 1));

included in their code which I don't quite understand why it is there since it will produce out a value of 0 every time.

what does this formula really do to generate the triangle?

What I have tried:

Yes, I have tried it on my code and it works perfectly.

这个公式本身没有任何意义,因为变量值和代码都很重要。

你需要显示代码。

This formula by itself means nothing because variables values and code around matters.
You need to show code around.
引用:

我不太明白它为什么会存在,因为它每次都会产生0的值。

I don't quite understand why it is there since it will produce out a value of 0 every time.

你认为每次产生0会是什么?

使用调试器可以帮助您理解此代码的工作方式


如果你不明白你的代码是做什么的,或者为什么它做了什么,答案是调试器

使用调试器查看代码正在执行的操作。它允许你逐行执行第1行并在执行时检查变量,它是一个令人难以置信的学习工具。



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

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



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

调试器中没有魔法,它没有找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。

What let you think it produce 0 every time ?
Using the debugger may help you to understand how this code work

hen 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. It 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[^]
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.
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.